From d0d5fea302e9fd71b6115c61aa8c39d757f25738 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Thu, 2 Nov 2023 20:21:10 -0700 Subject: [PATCH] mu --- .hammerspoon/init.fnl | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.hammerspoon/init.fnl b/.hammerspoon/init.fnl index aa9ba58..7b7b95e 100644 --- a/.hammerspoon/init.fnl +++ b/.hammerspoon/init.fnl @@ -54,21 +54,20 @@ (with-selection #(.. "[" $1 "]" "(" $2 ")")))]]) ;; cmd-shift-c: copy current url -(let [safari-applescript "tell application \"Safari\" to get URL of front document" - copy-safari (hotkey.new [:cmd :shift] :c - #(let [(_ obj _) (osascript.applescript safari-applescript)] - (pasteboard.setContents obj))) - copy-firefox (hotkey.new [:cmd :shift] :c #(eventtap.keyStrokes :yy)) - {: activated : deactivated} application.watcher - update-hotkey (fn [name event app] - (match [name event] - ["Firefox Developer Edition" activated] (copy-firefox:enable) - ["Firefox Developer Edition" deactivated] (copy-firefox:disable) - [:Safari activated] (copy-safari:enable) - [:Safari deactivated] (copy-safari:disable))) - watcher (application.watcher.new update-hotkey)] +(let [{: activated : deactivated} application.watcher + firefox (hotkey.new [:cmd :shift] :c #(eventtap.keyStrokes :yy)) + safari-applescript "tell application \"Safari\" to get URL of front document" + safari (hotkey.new [:cmd :shift] :c + #(let [(_ obj _) (osascript.applescript safari-applescript)] + (pasteboard.setContents obj))) + per-app {"Firefox Developer Edition" firefox :Safari safari} + update-app (fn [name event _app] + (match [(. per-app name) event] + [app-config activated] (app-config:enable) + [app-config deactivated] (app-config:disable))) + watcher (application.watcher.new update-app)] ;; hold onto watcher as a global so it doesn't get GC'ed - (set _G.watcher (watcher:start))) + (set _G.per-app-watcher (watcher:start))) ;;; Elgato Key Light Air