Using a macOS laptop with various available screen configurations is cumbersome. MacOS tries its best to reset the application windows to the state the screens were attached last time, but some vendors seem to find ways to break that feature.
And there currently is no good window manager available, who supports windows on multiple spaces on multiple screens.
With this in mind, Hammerspoon enters the state. Hammerspoon is an automation framework, that’s basically a bridge of macOS core management features (like keyboard and mouse handling, window management, etc.) to Lua.
There’s a single configuration file that can do various things. Additionally, there’s a library for it that allows spaces management, which still seems to be a big problem for applications.
So I wrote some Lua code to do my window management stuff:
- Identify application windows
- put them on the right screen
- put them on the right space
- maximize them
For a reference to others and a backup for me, I published that on Github.