Skip to content

Instantly share code, notes, and snippets.

@gabamnml
Created October 18, 2015 05:59
Show Gist options
  • Save gabamnml/8bf6e00d34219caa9037 to your computer and use it in GitHub Desktop.
Save gabamnml/8bf6e00d34219caa9037 to your computer and use it in GitHub Desktop.
Hammerspon script to change 'default' profile with custom for USB Keyboard using Karabiner App
local usbWatcher = nil
function usbDeviceCallback(data)
if (data["productName"] == "USB Keyboard") 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