Created
February 19, 2019 17:24
-
-
Save tobetchi/6d3a4105539be986f5ed4637cc3f20c3 to your computer and use it in GitHub Desktop.
Remap ctrl-h to delete for Skype.app with hammerspoon config
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
local function enableHotkeys(hotkeys) | |
for k, v in pairs(hotkeys) do | |
v:enable() | |
end | |
end | |
local function disableHotkeys(hotkeys) | |
for k, v in pairs(hotkeys) do | |
v:disable() | |
end | |
end | |
local function keyCode(key, mods) | |
mods = mods or {} | |
return function() | |
hs.eventtap.event.newKeyEvent(mods, key, true):post() | |
hs.timer.usleep(1000) | |
hs.eventtap.event.newKeyEvent(mods, key, false):post() | |
end | |
end | |
local function hotkey(mods, key, keyCode) | |
return hs.hotkey.new(mods, key, keyCode, nil, keyCode) | |
end | |
-- watch hotkey settings | |
local function handleGlobalAppEvent(name, event, app) | |
if event == hs.application.watcher.activated then | |
if name == 'Skype' then | |
enableHotkeys(skypeConf) | |
else | |
disableHotkeys(skypeConf) | |
end | |
end | |
end | |
appWatcher = hs.application.watcher.new(handleGlobalAppEvent) | |
appWatcher:start() | |
-- remap settings | |
skypeConf = { | |
hotkey({'ctrl'}, 'h', keyCode('delete')), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment