Last active
March 30, 2021 04:57
-
-
Save ojkelly/45dda0a5a7066c6a79a038ece8bde55a to your computer and use it in GitHub Desktop.
My hammerspoon config
This file contains 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 characters
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 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 | |
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 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 characters
-- 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment