Last active
March 3, 2019 01:52
-
-
Save svermeulen/996213b4c6747c8c20f5a498ca67f932 to your computer and use it in GitHub Desktop.
Hammerspoon to reload karabiner (12.2.0) complex modification. NOTE: Assumes 1 entry and that it's listed at the top in the add popup
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
hs.urlevent.bind("reloadKarabinerConfig", function(eventName, params) | |
hs.application.launchOrFocusByBundleID("org.pqrs.Karabiner-Elements.Preferences") | |
local delay = 10 | |
hs.timer.doAfter(1, function() | |
-- Select the complex modifications tab | |
hs.eventtap.keyStroke({}, "right", delay) | |
hs.eventtap.keyStroke({}, "right", delay) | |
hs.timer.doAfter(1, function() | |
-- Go to the list | |
hs.eventtap.keyStroke({}, "tab", delay) | |
hs.eventtap.keyStroke({}, "tab", delay) | |
hs.eventtap.keyStroke({}, "down", delay) | |
-- Delete single entry | |
hs.eventtap.keyStroke({}, "space") | |
-- Click the Add button | |
hs.eventtap.keyStroke({}, "tab", delay) | |
hs.eventtap.keyStroke({}, "tab", delay) | |
hs.eventtap.keyStroke({}, "tab", delay) | |
hs.eventtap.keyStroke({}, "tab", delay) | |
hs.eventtap.keyStroke({}, "space") | |
-- Add the top most entry | |
hs.eventtap.keyStroke({}, "tab", delay) | |
hs.eventtap.keyStroke({}, "down", delay) | |
hs.eventtap.keyStroke({}, "down", delay) | |
hs.eventtap.keyStroke({}, "space") | |
-- Quit karabiner | |
hs.eventtap.keyStroke({"cmd"}, "q") | |
end) | |
end) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment