diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..5324238 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,5 @@ +{ + "diagnostics.globals": [ + "insertLink" + ] +} \ No newline at end of file diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua index 231ac83..4acc3f9 100644 --- a/hammerspoon/init.lua +++ b/hammerspoon/init.lua @@ -35,9 +35,14 @@ hs.audiodevice.watcher:start() local slackAppName = "Slack" -hs.hotkey.bind({ "cmd" }, "k", function() - local focusedApp = hs.application.frontmostApplication() - if focusedApp:name() == slackAppName then - hs.eventtap.keyStroke({ "cmd", "shift" }, "u") - end +local insertLink = hs.hotkey.new({ "cmd" }, "k", function() + hs.eventtap.keyStroke({ "cmd", "shift" }, "u") end) + +hs.window.filter.new(slackAppName) + :subscribe(hs.window.filter.windowFocused, function() + insertLink:enable() + end) + :subscribe(hs.window.filter.windowUnfocused, function() + insertLink:disable() + end)