Skip to content

Instantly share code, notes, and snippets.

@tobetchi
Created February 19, 2019 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tobetchi/6d3a4105539be986f5ed4637cc3f20c3 to your computer and use it in GitHub Desktop.
Save tobetchi/6d3a4105539be986f5ed4637cc3f20c3 to your computer and use it in GitHub Desktop.
Remap ctrl-h to delete for Skype.app with hammerspoon config
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