MacOS Window Management using Hammerspoon

dploeger profile image Dennis Ploeger Originally published at dennis.dieploegers.de on ・1 min read

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.

Have fun.


Posted on by:

dploeger profile

Dennis Ploeger


I'm a Senior DevOps Architect and publish most of my projects as open source. I have a wife, a son and a real life in Hamm, Germany. In my part-time I enjoy making music and acting. (He/him)


markdown guide