quitter: fix crash when app terminates during window unfocus
Assisted-by: Claude Opus 4.5 via Claude Code
change qwvqsusrrlpqkpvulnyzmsntvtxtvlnz
commit 597bf11ac279168d500c700e88a44dee54e6dbdc
author Alpha Chen <alpha@kejadlen.dev>
date
parent yzlltwmr
diff --git a/.hammerspoon/quitter.fnl b/.hammerspoon/quitter.fnl
index ecad984c..2a956ac2 100644
--- a/.hammerspoon/quitter.fnl
+++ b/.hammerspoon/quitter.fnl
@@ -45,12 +45,14 @@
       (focused-win:focus))))
 
 (fn unmark [app]
-  (let [bundle-id (app:bundleID)
-        t (?. to-kill bundle-id)]
-    (when (not= t nil)
-      (log.i (.. "unmarking " (app:name)))
-      (t:stop)
-      (set (. to-kill bundle-id) nil))))
+  ;; app can be nil - maybe when a window loses focus because its app is terminating?
+  (when app
+    (let [bundle-id (app:bundleID)
+          t (?. to-kill bundle-id)]
+      (when (not= t nil)
+        (log.i (.. "unmarking " (app:name)))
+        (t:stop)
+        (set (. to-kill bundle-id) nil)))))
 
 (fn mark [app]
   (when (and (not (contains config.permanent-apps (app:name))) (= (app:kind) 1))