hammerspoon: sync

This commit is contained in:
Konstantin Bukley
2021-01-14 14:28:52 +02:00
parent 284c85d37d
commit dc5f007df8
12 changed files with 1117 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
-- Credit for this implementation goes to @arbelt and @jasoncodes 🙇⚡️😻
--
-- https://gist.github.com/arbelt/b91e1f38a0880afb316dd5b5732759f1
-- https://github.com/jasoncodes/dotfiles/blob/ac9f3ac/hammerspoon/control_escape.lua
sendEscape = false
lastMods = {}
ctrlKeyHandler = function()
sendEscape = false
end
ctrlKeyTimer = hs.timer.delayed.new(0.15, ctrlKeyHandler)
ctrlHandler = function(evt)
local newMods = evt:getFlags()
if lastMods["ctrl"] == newMods["ctrl"] then
return false
end
if not lastMods["ctrl"] then
lastMods = newMods
sendEscape = true
ctrlKeyTimer:start()
else
if sendEscape then
keyUpDown({}, 'escape')
end
lastMods = newMods
ctrlKeyTimer:stop()
end
return false
end
ctrlTap = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, ctrlHandler)
ctrlTap:start()
otherHandler = function(evt)
sendEscape = false
return false
end
otherTap = hs.eventtap.new({hs.eventtap.event.types.keyDown}, otherHandler)
otherTap:start()