Created
February 2, 2017 00:06
-
-
Save yohm/a2c8f4f76a9ad64fcbafda4072619e4c to your computer and use it in GitHub Desktop.
My configuration of hammerspoon
This file contains hidden or 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 function disableAllHotkeys() | |
for k, v in pairs(hs.hotkey.getHotkeys()) do | |
v['_hk']:disable() | |
end | |
end | |
local function enableAllHotkeys() | |
for k, v in pairs(hs.hotkey.getHotkeys()) do | |
v['_hk']:enable() | |
end | |
end | |
local function keyCode(key, modifiers) | |
modifiers = modifiers or {} | |
return function() | |
disableAllHotkeys() | |
hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), true):post() | |
hs.timer.usleep(1000) | |
hs.eventtap.event.newKeyEvent(modifiers, string.lower(key), false):post() | |
enableAllHotkeys() | |
end | |
end | |
local function remapKey(modifiers, key, keyCode) | |
hs.hotkey.bind(modifiers, key, keyCode, nil, keyCode) | |
end | |
remapKey({'ctrl'}, ';', keyCode(';', {})) | |
remapKey({}, ';', keyCode('return')) | |
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function() | |
hs.reload() | |
end) | |
hs.alert.show("Config loaded") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment