Last active
March 30, 2021 04:57
-
-
Save ojkelly/45dda0a5a7066c6a79a038ece8bde55a to your computer and use it in GitHub Desktop.
Revisions
-
ojkelly revised this gist
Jul 15, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,8 @@ function usbDeviceCallback(data) if string.match(data["productName"], "Yubikey") then if (data["eventType"] == "added") then hs.notify.show("Yubikey", "You just connected", data["productName"]) -- wake the screen up, so knock will activate -- get knock here http://www.knocktounlock.com os.execute("caffeinate -u -t 5") elseif (data["eventType"] == "removed") then -- replace +000000000000 with a phone number registered to iMessage -
ojkelly renamed this gist
Jul 15, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ojkelly created this gist
Jul 15, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ local usbWatcher = nil -- This is our usbWatcher function -- lock when yubikey is removed function usbDeviceCallback(data) -- this line will let you know the name of each usb device you connect, useful for the string match below hs.notify.show("USB", "You just connected", data["productName"]) -- Replace "Yubikey" with the name of the usb device you want to use. if string.match(data["productName"], "Yubikey") then if (data["eventType"] == "added") then hs.notify.show("Yubikey", "You just connected", data["productName"]) -- wake the screen up, so knock will acti os.execute("caffeinate -u -t 5") elseif (data["eventType"] == "removed") then -- replace +000000000000 with a phone number registered to iMessage hs.messages.iMessage("+000000000000", "Your Yubikey was just removed from your Work iMac.") -- this locks to screensaver os.execute("pmset displaysleepnow") end end end -- Start the usb watcher usbWatcher = hs.usb.watcher.new(usbDeviceCallback) usbWatcher:start() This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ -- get a dreamcheeky led screen like this http://dreamcheeky.com/led-message-board -- get dcled from here https://github.com/kost/dcled local usbWatcher = nil -- This is our usbWatcher function -- lock when yubikey is removed function usbDeviceCallback(data) hs.notify.show("USB", "You just connected", data["productName"]) -- Replace "Yubikey" with the name of the usb device you want to use. if string.match(data["productName"], "Yubikey") then if (data["eventType"] == "added") then hs.notify.show("Yubikey", "You just connected", data["productName"]) -- wake the screen up, so knock will acti os.execute("caffeinate -u -t 5") setDcled('! BUSY ! BUSY ! BUSY ') elseif (data["eventType"] == "removed") then -- replace +000000000000 with a phone number registered to iMessage hs.messages.iMessage("+000000000000", "Your Yubikey was just removed from your Work iMac.") setDcled('THE DEV IS OUT') -- this locks to screensaver os.execute("pmset displaysleepnow") end end end -- Start the usb watcher usbWatcher = hs.usb.watcher.new(usbDeviceCallback) usbWatcher:start() local dcmenubar = hs.menubar.new() function setDcled(message) dcmenubar:setTitle("led: " .. message) hs.notify.show("dcled", "set:", message) -- os.execute("ps -ef | grep dcled | grep -v grep | awk '{print $2}' | xargs kill -9") os.execute("pkill -9 dcled") os.execute('/usr/local/bin/dcled -s 30 --repeat -m \'' .. message .. '\' &') end hs.hotkey.bind({"cmd"}, "f4", function() setDcled('BUSY <---- SEE RUPERT ') end) hs.hotkey.bind({"cmd"}, "f5", function() setDcled(':) :) :)') end) hs.hotkey.bind({"cmd"}, "f6", function() setDcled('IN A MEETING') end) hs.hotkey.bind({"cmd"}, "f7", function() setDcled('LUNCH') end) hs.hotkey.bind({"cmd"}, "f8", function() setDcled('THE DEV IS OUT') end) hs.hotkey.bind({"cmd"}, "f9", function() setDcled('THE DEV IS IN') end) hs.hotkey.bind({"cmd"}, "f10", function() setDcled('! BUSY ! BUSY ! BUSY ') end) hs.hotkey.bind({"cmd"}, "f11", function() setDcled(' !!! FIXING A CRITICAL BUG !!! DO NOT INTERUPT ') end) hs.hotkey.bind({"cmd"}, "f12", function() setDcled(' !!! DO NOT INTERUPT ') end)