Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local usbWatcher = nil
- function usbDeviceCallback(data)
- -- 4176/1031 is Yubico/Yubikey4
- if (data["vendorID"] == 4176 and data["productID"] == 1031) then
- if (data["eventType"] == "added") then
- hs.caffeinate.set("displayIdle", false, false)
- elseif (data["eventType"] == "removed") then
- hs.caffeinate.set("displayIdle", true, false)
- hs.caffeinate.startScreensaver()
- end
- end
- end
- usbWatcher = hs.usb.watcher.new(usbDeviceCallback)
- usbWatcher:start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement