DEV Community

Mingke Tu
Mingke Tu

Posted on

My Mac windows kept landing on the wrong Space after every monitor swap, so I wrote a small app for it

I use a MacBook with one external monitor at a time, and I swap between a few monitors during the week. Every time I plug a monitor back in, macOS brings the windows back to that screen, but not to the Space they were on. Chrome ends up on desktop 3, Slack on desktop 1, and I spend the first few minutes dragging things around.

I wanted something that remembers, for each monitor, which Space every window belongs to. I couldn't find a tool that did exactly that, so I wrote LayoutKeeper, a small menu bar app.

What it does:

  • Saves a window layout per external monitor, keyed by the monitor's EDID, including which Space each window is on.
  • When that monitor is plugged back in, it moves windows back to their saved Space and position.
  • Tells Chrome windows apart by profile, so work and personal windows go back to the right places.
  • Adds brightness keys for external monitors.

What it doesn't do yet: when you unplug and go back to the built-in screen only, it doesn't restore a separate layout for that. There is an open issue for it (#2) and it's the next thing I want to build.

It's free and open source (GPL-3.0), with builds for Apple Silicon and Intel:
https://github.com/tumingke0/LayoutKeeper

If you swap monitors a lot, I'd like to know whether it works with your setup.

Top comments (0)