[hammerspoon] Workaround for <esc> in Safari
change
commit 6e631d05b837d9807145fb160ab5f5b5d5a5d214
author Alpha Chen <alpha.chen@gmail.com>
date
parent 3fa8a87c
diff --git a/.hammerspoon/init.lua b/.hammerspoon/init.lua
index aa6320e3..c48c0ba2 100644
--- a/.hammerspoon/init.lua
+++ b/.hammerspoon/init.lua
@@ -3,14 +3,20 @@ local mash = {"cmd", "alt", "ctrl", "shift"}
 
 -- Application shortcuts
 
-hs.hotkey.bind({}, "escape", function()
+local wf = hs.window.filter
+local safari_esc = hs.hotkey.new({}, "escape", function() end, function()
   if current_app():name() == "Safari" then
     hs.eventtap.keyStroke({"alt"}, "escape")
-  else
-    hs.eventtap.keyStroke({}, "escape")
   end
 end)
 
+wf.new("Safari"):subscribe(wf.windowFocused, function()
+  safari_esc:enable()
+end):subscribe(wf.windowUnfocused, function()
+  safari_esc:disable()
+end)
+
+
 -- hs.hotkey.bind({"cmd", "shift"}, "[", function()
 --   current_app():selectMenuItem({"Window", "Select Previous Tab"})
 -- end)