When you unplug an external display, macOS moves its windows onto the MacBook's screen, usually stacked and at sizes that don't fit. When you plug the display back in, macOS often leaves them on the laptop, so you drag every window back by hand. macOS has no setting that saves a window layout per display. To get the layout back automatically you need a window manager that remembers where each window was for each display setup; Toolnotch's Wyndow does that, and so do a few others listed below.
Why macOS does this
A window's position is a pair of coordinates in one big space that spans all your displays. When a display disappears, any window sitting in its part of that space has nowhere to be, so macOS moves it onto a display that still exists. It picks a position that keeps the window visible, and if the window is bigger than the laptop screen, macOS shrinks it or lets it overflow.
When the display comes back, macOS sometimes returns windows to it, especially after a short disconnect or a quick sleep. Often it doesn't: the windows already have valid positions on the laptop, and macOS keeps them there. Docks and some USB-C or DisplayPort monitors make it worse, because they briefly disconnect during wake and trigger the same shuffle every morning.
Apple's window tiling in macOS Sequoia (drag a window to an edge, or the green button's Move & Resize menu) arranges windows but doesn't save arrangements, so it doesn't help here.
What you can try for free
Check Mission Control's Spaces setting. In System Settings › Desktop & Dock › Mission Control, "Displays have separate Spaces" is on by default. Leave it on: with it off, a single Space spans both displays and unplugging tends to scramble more windows. Changing it requires logging out.
Assign apps to a display. Right-click an app in the Dock › Options › Assign To › This Desktop, while the app is on the external display. macOS then tries to open that app's windows on that display's desktop. It helps for apps you relaunch, not for windows already open when you unplug.
Avoid unplugging while the Mac is asleep, when you can. Waking with a different set of displays than the Mac went to sleep with is the case macOS handles worst. Unplugging while awake and waiting a few seconds before closing the lid gives it a cleaner transition.
Script it. Keyboard Maestro users save window positions with a macro and run it on reconnect. It works, but you maintain the macro every time your layout changes.
None of these restores a layout on its own.
Apps that restore the layout
Several window managers save positions per display setup. Rectangle Pro lists an option to restore a display's layout when it is reconnected; the free Rectangle doesn't have it. Display Maid saves window positions per display configuration and restores them on connect or disconnect. Moom has layouts you can trigger when the number of displays changes. Check each one's current version: this is a hard problem, and the details (sleep, Spaces, apps with many windows) are where they differ.
The rest of this guide covers how Wyndow, the window manager in Toolnotch, handles it, because that's the one I build and can describe exactly.
What Wyndow does when you unplug
- You pull the cable. Wyndow waits for macOS to finish moving windows and for the displays to settle, so it doesn't fight macOS halfway through.
- Each window that was on the external display goes to the matching zone on the laptop, on top. A window on the right half of the monitor lands on the right half of the MacBook. A full-screen-sized window fills the MacBook. A left two-thirds stays a left two-thirds.
- The windows that were already on the MacBook don't move.
- An island under the notch tells you what happened: « Moved 3 windows · to Built-in Retina Display ». ⌃⌥⌫ undoes the whole move in one go.
Windows that macOS put on a Space you're not looking at are placed as soon as you switch to that Space; the island says « 3 windows placed when you're back ».
What Wyndow does when you plug back in
Wyndow waits again for the displays to settle, then sends each window back to exactly where it was on the external display, the same position and size. The island says « Restored 3 windows · Built-in Retina Display + Studio Display », and ⌃⌥⌫ undoes it if you'd rather keep things where they are.
Wyndow remembers one layout per combination of displays and tells monitors apart by model and serial number, so a different monitor at a hotel desk doesn't receive your office layout.
The cases that usually break
These are the situations that defeat simpler tools, and how Wyndow treats each:
- Unplug, close the lid, open it at home. Wyndow keeps the layout through sleep, an app update or a relaunch, and waits for macOS to list your windows after wake before placing them. When you open the lid on the MacBook alone, each window is where it was the last time you used the MacBook alone.
- Windows you just arranged. Snap two windows side by side on the monitor, then unplug: they come back side by side on the MacBook, not where they were this morning.
- Terminal and other windows whose title keeps changing. Wyndow recognises them anyway, so a Terminal running a build isn't treated as a new window.
- Native tabs. A Terminal or Finder window with several tabs moves as one window and keeps the right height when you switch tabs.
Save a layout you can call back: desks
Restoring on replug covers the daily unplug. For setups you switch between on purpose (writing, coding, a call), Wyndow has desks:
- ⌘S in the Wyndow panel saves where every window is, per display, across all your macOS Spaces.
- ⌘1 to ⌘5 apply a desk. The Space you're on is placed at once, each other Space as soon as you go to it.
- A desk can come back by itself when you plug in the same displays it was saved with.
- « Quit the other apps » on a desk offers to quit everything that isn't part of it. It always asks first, never quits Finder, menu bar apps or music that's playing, and ⌃⌥⌫ reopens them.
- Desks, « Tidy windows » and « Undo last action » are also available in Apple's Shortcuts app for your automations.
Setting it up
- Download Toolnotch from toolnotch.app and open it. It runs on macOS 15 Sequoia or later, Apple silicon or Intel.
- Give it Accessibility access when it asks (System Settings › Privacy & Security › Accessibility). Every Mac window manager needs it to move windows.
- Use your Mac as usual for half a minute with the display plugged in, so Wyndow learns where windows are. There's nothing to configure for the unplug and replug behaviour.
- If you already run Rectangle, Magnet or another window manager, Toolnotch tells you. Turn off the overlapping one, or turn off Wyndow and keep the rest of Toolnotch.
The home page has a live demo: pull the cable between a Studio Display and a MacBook, with Wyndow and with macOS alone, and watch where the windows go.
FAQ
Does this work on a Mac without a notch, like a Mac mini?
Yes. On a display without a notch, Toolnotch's panels and islands hang from the middle of the menu bar.
Will it move windows I placed on the laptop on purpose?
No. On unplug, only the external display's windows move. On replug, only windows that came from that display go back.
What about full-screen apps?
Wyndow never moves a full-screen window. macOS keeps full-screen apps in their own Spaces.
Does Wyndow also snap windows?
Yes: ⌃⌥ with the arrows for halves, press again to cycle ½ → ⅔ → ⅓, ⌃⌥↩ to fill the screen and again to put the window back, or drag a window up to the notch and drop it on a zone.