Skip to content

Instantly share code, notes, and snippets.

@alexander-clark
Created October 2, 2017 20:56
Show Gist options
  • Save alexander-clark/10c71d3299d387dee327c1c4b47f63c2 to your computer and use it in GitHub Desktop.
Save alexander-clark/10c71d3299d387dee327c1c4b47f63c2 to your computer and use it in GitHub Desktop.
Hammerspoon - switch Mac Input Source / keyboard layout on Kinesis Advantage 2 connect / disconnect
usbWatcher = nil
function usbDeviceCallback(data)
if (data["productName"] == "Advantage2 Keyboard") then
if (data["eventType"] == "added") then
hs.keycodes.setLayout("U.S.")
elseif (data["eventType"] == "removed") then
hs.keycodes.setLayout("Dvorak")
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