hammerspoon: Auto-reload aerospace config on file changes
Assisted-by: Claude Opus 4.5 via Claude Code
change oqmvmtptottklyvosvplrnrzmnwqlnoq
commit afd69b638b0c1642ef456c2f0c05faabe46fe313
author Alpha Chen <alpha@kejadlen.dev>
date
parent qwvqsusr
diff --git a/.hammerspoon/init.fnl b/.hammerspoon/init.fnl
index f74a2189..15ccf261 100644
--- a/.hammerspoon/init.fnl
+++ b/.hammerspoon/init.fnl
@@ -8,6 +8,7 @@
         : logger
         : notify
         : pasteboard
+        : pathwatcher
         : screen
         : urlevent
         : window} hs)
@@ -62,6 +63,20 @@
 
 (_G.screen-watcher:start)
 
+;;; reload aerospace on config changes
+
+(let [home (os.getenv :HOME)
+      aerospace-config (.. home :/.config/aerospace/aerospace.toml)]
+  (set _G.aerospace-watcher
+       (pathwatcher.new aerospace-config
+                        (fn []
+                          (execute "/opt/homebrew/bin/aerospace reload-config")
+                          (let [n (notify.new {:title :Aerospace
+                                               :informativeText "Config reloaded"
+                                               :withdrawAfter 2})]
+                            (n:send)))))
+  (_G.aerospace-watcher:start))
+
 ;;; wm
 
 (let [{: init : step} (require :wm)]