Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. local usbWatcher = nil
  2.  
  3. function usbDeviceCallback(data)
  4. -- 4176/1031 is Yubico/Yubikey4
  5. if (data["vendorID"] == 4176 and data["productID"] == 1031) then
  6. if (data["eventType"] == "added") then
  7. hs.caffeinate.set("displayIdle", false, false)
  8. elseif (data["eventType"] == "removed") then
  9. hs.caffeinate.set("displayIdle", true, false)
  10. hs.caffeinate.startScreensaver()
  11. end
  12. end
  13. end
  14.  
  15. usbWatcher = hs.usb.watcher.new(usbDeviceCallback)
  16. usbWatcher:start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement