I have triggers set up if specific devices are connected to switch presets but i was wondering if there was a way for it to check if devices are connected when the lid opens?
You can run a script on lid open that would check your connected devices. Easiest would probably with a "if script returns true" condition:
Here is an example script that should work if you provide the appropriate vendorid and productid in hex:
async function checkDevice() {
let vendorID = "0x123";
let productID = "0x124";
let script = `/usr/sbin/ioreg -p IOUSB -l | awk '/idVendor/{v=$3}/idProduct/{p=$3; if(v=="${vendorID}" && p=="${productID}") found=1} END{exit !found}'`;
let result = await runShellScript({script});
if(result == 1){
return true;
} else {
return false;
}
}
thank you
