[hammerspoon] replace MiroWindowsManager
diff --git a/.hammerspoon/init.fnl b/.hammerspoon/init.fnl
index b67f1b92..ea33a474 100644
--- a/.hammerspoon/init.fnl
+++ b/.hammerspoon/init.fnl
@@ -50,6 +50,12 @@
(let [quitter (require :quitter)]
(quitter:start))
+;;; wm
+
+(let [{: init : step} (require :wm)]
+ (init)
+ (hotkey.bind mash :m step))
+
;;; Spoons
(loadSpoon :SpoonInstall)
@@ -58,15 +64,6 @@
(set window.animationDuration 0.0)
-;; fnlfmt: skip
-(let [hotkeys {:up [mash :k]
- :left [mash :h]
- :down [mash :j]
- :right [mash :l]
- :fullscreen [mash :m]
- :nextscreen [mash :n]}]
- (Install:andUse :MiroWindowsManager {: hotkeys}))
-
(Install:andUse :SleepCorners {:config {:feedbackSize 25 :neverSleepCorner "*"}
:start true})
diff --git a/.hammerspoon/wm.fnl b/.hammerspoon/wm.fnl
new file mode 100644
index 00000000..df65d25c
--- /dev/null
+++ b/.hammerspoon/wm.fnl
@@ -0,0 +1,28 @@
+;; Ported from https://github.com/miromannino/miro-windows-manager/blob/master/MiroWindowsManager.spoon/init.lua#L95-L121
+
+(local {:fnutils {:indexOf index-of}} hs)
+
+(local log (hs.logger.new :init :info))
+
+(local full {:x 0 :y 0 :w 8 :h 8})
+(local three-quarters {:x 1 :y 1 :w 6 :h 6})
+(local half {:x 2 :y 2 :w 4 :h 4})
+(local steps [full three-quarters half])
+
+(λ init []
+ (hs.grid.setGrid :8x8)
+ (hs.grid.setMargins "0,0"))
+
+(λ step []
+ (when (hs.window.focusedWindow)
+ (let [win (hs.window.frontmostWindow)
+ screen (win:screen)
+ cell (hs.grid.get win screen)
+ next-step-index (-> (index-of steps cell)
+ (or -1)
+ (% (length steps))
+ (+ 1))
+ next-step (. steps next-step-index)]
+ (hs.grid.set win next-step screen))))
+
+{: init : step}