Skip to content

Instantly share code, notes, and snippets.

@KasaiMagi
Last active December 18, 2015 18:30
Show Gist options
  • Save KasaiMagi/b153e3031a28fc8a6e6e to your computer and use it in GitHub Desktop.
Save KasaiMagi/b153e3031a28fc8a6e6e to your computer and use it in GitHub Desktop.
Karabiner Switch when KB plugged in
local usbWatcher = nil
function usbDeviceCallback(data)
if (data["productName"] == "Quickfire TKL 6keys") then
if (data["eventType"] == "added") then
hs.execute('/Applications/Karabiner.app/Contents/Library/bin/karabiner select 1')
elseif (data["eventType"] == "removed") then
hs.execute('/Applications/Karabiner.app/Contents/Library/bin/karabiner select 0')
end
end
end
usbWatcher = hs.usb.watcher.new(usbDeviceCallback)
usbWatcher:start()
@KasaiMagi
Copy link
Author

Using Hammerspoon (http://www.hammerspoon.org/) with the USB watcher ability, add this code to init.lua, update the keyboard name, and set numbers to correct Karabiner profiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment