Last active
December 18, 2015 18:30
-
-
Save KasaiMagi/b153e3031a28fc8a6e6e to your computer and use it in GitHub Desktop.
Karabiner Switch when KB plugged in
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 | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.