[hammerspoon]
change
commit e6ecf4f909ce545e6316833705f8022a4463467e
author Alpha Chen <alpha@kejadlen.dev>
date
parent b612ea27
diff --git a/.hammerspoon/init.fnl b/.hammerspoon/init.fnl
index e956aade..f88d152a 100644
--- a/.hammerspoon/init.fnl
+++ b/.hammerspoon/init.fnl
@@ -93,7 +93,8 @@
                     ["^https://(.*%.?)bankofamerica.com/?" handlers.safari]
                     ["^https://(.*%.?)betterment.com/?" handlers.safari]
                     ["^https://(.*%.?)schwab.com/?" handlers.safari]
-                    ["^https://(.*%.?)chase.com/?" handlers.safari]]
+                    ["^https://(.*%.?)chase.com/?" handlers.safari]
+                    ["^https://(.*%.?)xfinity.com/?" handlers.safari]]
       url-redir-decoders [[:sci-hub
                            "^https://doi.org/(.*)"
                            "https://sci-hub.st/%1"]]]
@@ -109,7 +110,10 @@
 (when (fs.attributes :local.fnl)
   (require :local))
 
-(: (notify.new {:title :Hammerspoon
-                :informativeText "Config loaded"
-                :withdrawAfter 2}) :send)
+(let [n (notify.new {:title :Hammerspoon
+                     :informativeText "Config loaded"
+                     :withdrawAfter 2})]
+  (n:send))
 
+;; hold onto globals so they don't get GC'ed?
+{}
diff --git a/.hammerspoon/key-light-air.fnl b/.hammerspoon/key-light-air.fnl
index bb89c011..0b066b2b 100644
--- a/.hammerspoon/key-light-air.fnl
+++ b/.hammerspoon/key-light-air.fnl
@@ -1,4 +1,7 @@
 ;;; Elgato Key Light Air
+;;;
+;;; Run `package.loaded["key-light-air"]["find-hostname"]()`
+;;; to find the hostname of the Key Light Air
 
 (local {: bonjour : caffeinate : http : json : logger : usb} hs)
 (local log (logger.new :key-light-air :info))
diff --git a/.hammerspoon/quitter.fnl b/.hammerspoon/quitter.fnl
index 09cb0915..b6dc0cca 100644
--- a/.hammerspoon/quitter.fnl
+++ b/.hammerspoon/quitter.fnl
@@ -1,4 +1,10 @@
-(local {: application : caffeinate : fnutils : logger : timer : window} hs)
+(local {: application
+        : caffeinate
+        : fnutils
+        : logger
+        : notify
+        : timer
+        : window} hs)
 
 (local {: contains : ifilter} fnutils)
 
@@ -8,6 +14,7 @@
                   :Arc
                   "Firefox Developer Edition"
                   :Ghostty
+                  :LibreWolf
                   :Miniflux
                   :Phanpy
                   :Obsidian])
@@ -15,9 +22,16 @@
 (local to-kill {})
 
 (fn kill [app]
+  ;; in theory if the app is frontmost it shouldn't
+  ;; be marked, but an extra precaution since we never
+  ;; want to kill the focused app
   (when (not (app:isFrontmost))
-    (log.i (.. "killing " (app:name)))
-    (let [focused-win (window.focusedWindow)]
+    (let [app-name (app:name)
+          focused-win (window.focusedWindow)
+          msg (.. "Killing " app-name)
+          n (notify.new {:title :Quitter :informativeText msg :withdrawAfter 2})]
+      (log.i msg)
+      (n:send)
       (app:kill)
       (focused-win:focus))))
 
@@ -48,6 +62,7 @@
                               :Arc false
                               "Firefox Developer Edition" false
                               :Ghostty false
+                              :LibreWolf false
                               :Miniflux false
                               :Phanpy false
                               :Obsidian false
@@ -61,6 +76,6 @@
                  window.filter.windowUnfocused #(mark ($1:application))}))
 
 ;; use global so this isn't GC'ed
-(set _G.quitter {: to-kill})
+(set _G.quitter {: cw : to-kill : wf})
 
 {: start}
diff --git a/.hammerspoon/utils.fnl b/.hammerspoon/utils.fnl
index ba121f59..55602215 100644
--- a/.hammerspoon/utils.fnl
+++ b/.hammerspoon/utils.fnl
@@ -1,5 +1,4 @@
-(local {: application : eventtap : execute : logger : pasteboard : uielement}
-       hs)
+(local {: eventtap : execute : logger : pasteboard : uielement} hs)
 
 (local log (logger.new :utils :info))
 
@@ -18,8 +17,7 @@
 
 (fn replace-selection [cb]
   "Replaces the current selection with the return value of the callback"
-  (let [app (application.frontmostApplication)
-        prev-pasteboard (pasteboard.getContents)
+  (let [prev-pasteboard (pasteboard.getContents)
         e (uielement.focusedElement)
         text (if e (e:selectedText)
                  (do
@@ -31,8 +29,7 @@
 
 (fn run [...]
   "Executes a list of commands"
-  (accumulate [last nil _ cmd (ipairs [...])]
+  (each [_ cmd (ipairs [...])]
     (execute cmd)))
 
 {: chomp : paste : replace-selection : run}
-