[hammerspoon] debounce sketchybar reload
change wtpqukxttwoloxmyqwysprkxmpqvmwnq
commit 4962cd4f000c196275ae28a7d10c65986f55b4f4
author Alpha Chen <alpha@kejadlen.dev>
date
parent mxzzoxoz
diff --git a/.hammerspoon/init.fnl b/.hammerspoon/init.fnl
index b4ac44da..c2d14580 100644
--- a/.hammerspoon/init.fnl
+++ b/.hammerspoon/init.fnl
@@ -16,7 +16,7 @@
 ; (set logger.defaultLogLevel :info)
 
 (local {: mash : smash : modal-bind} (require :hotkey))
-(local {: chomp : paste : replace-selection : run} (require :utils))
+(local {: chomp : debounce : paste : replace-selection : run} (require :utils))
 (local little-ff (require :little-ff))
 
 ;; debugging
@@ -52,12 +52,13 @@
 (let [quitter (require :quitter)]
   (quitter:start))
 
-;;; sketchybar on screen changes
+;;; reload sketchybar on screen changes
 
 (set _G.screen-watcher
-     (screen.watcher.new (fn []
-                           (log:i "Screen configuration changed, reloading sketchybar")
-                           (execute "/opt/homebrew/bin/sketchybar --reload"))))
+     (screen.watcher.new #(debounce 1.0
+                                    (fn []
+                                      (log:i "Screen configuration changed, reloading sketchybar")
+                                      (execute "/opt/homebrew/bin/sketchybar --reload")))))
 
 (_G.screen-watcher:start)