Wherein I continue to try to recreate my long-loved but long-lost Linux window manager UX.
The bits of MacOS that handle space naming and switching (Mission Control? Dock.app?) aren't publicly consumable / there isn't a public API for them. That sucks because it leads to workarounds, some of them harmful, like the (otherwise-fantasic) yabai needing SIP to be disabled for full functionality (it's in the very name, "yabai" means dangerous).
In Hammerspoon it works differently. For several of its operations, hs.spaces brings up the Mission Control UI and then scrapes its accessibility axuielements, then interacts with those. This works and I appreciate that I don't have to disable SIP... but it's slow and causes distracting stuff to briefly appear on the screen.
I miss how instantaneous switching workspaces is in XMonad, ion3, pretty much any X windows window manager. I don't really use any of the other parts of Mission Control (I don't use the weird-to-me concept of a "full screen" app just making itself a new Space, I don't name spaces or ever really re-order them), so maybe there's something I can do to make switching spaces faster?
I finally realized that since I already have system keystrokes that switch between spaces
I can just make Hammerspoon emit those keystrokes instead of using hs.spaces.gotoSpace()
. The only issue is that I have to do a little bit of bookkeeping to keep track of space numbers.
This should work even if you use different shortcuts like the common "hyper" thing where you twist your hand into a claw because MacOS doesn't have a modifier key like Mod4
that you can dedicate to window management, you just have to change the hs.eventtap.keyStroke
call in previous_spaces.lua
.