Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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