If you plug two or more identical external monitors into an Apple Silicon Mac, let it go to sleep and wake it back up, you might find that the left and right monitors have swapped places, or that all of your windows have stacked onto one monitor.
It’s because Apple Silicon Macs wake up faster than your external monitors do and, when two or more identical displays are plugged in, they might report identical or ambiguous information to macOS.
This issue is fixable. There are free command-line tools you can combine (displayplacer and sleepwatcher), or you can get a dedicated macOS utility that restores both your display arrangement and window positions across screens and Spaces after sleep.
Disclosure: I’m the developer of Universal Display Magnet at Clever Mechanisms, so I’m going to go through the built-in macOS settings you can tweak first, and then compare third-party tools alongside my own app.
Why macOS swaps monitors and moves windows after sleep
This problem usually crops up when you wake your MacBook from sleep and reconnect via a Thunderbolt or DisplayLink dock. When macOS wakes, it queries your external displays before they’ve all finished waking up, and this can cause two things to break:
- Your display arrangement (which monitor is on the left and which is on the right) is assigned to whichever monitor responds first.
- If one external display goes offline during sleep, the
WindowServerprocess evacuates all of its windows onto the display that’s still online. By the time your missing monitor wakes up a couple seconds later, macOS almost never restores those windows to the correct monitor or Space.
macOS saves your layouts to com.apple.windowserver.displays and identifies your screens using EDID data reported by the display hardware: the vendor, model, and serial number. When two identical monitors are connected, they share the same vendor and model and often report a duplicate or blank serial number. If a dock changes the order in which the two monitors respond, macOS can’t tell them apart.
If you restore only window positions, you may still have a problem. If your left and right monitors have been swapped after sleep, those windows are restored to the wrong monitors.
Built-in macOS settings to check first
-
System Settings > Desktop & Dock > Mission Control: Turn off Automatically rearrange Spaces based on most recent use (otherwise the order of your Spaces will rearrange based on which monitor wakes first or where your cursor is when you wake your Mac) -
System Settings > Desktop & Dock > Mission Control: Leave Displays have separate Spaces turned on. Turning this setting off will merge your displays into one Space and discard per-display state, including menu bars. - Right click an application’s icon in the Dock and select
Options > Assign To > This Desktop. Newly opened windows will open on the correct monitor (but it won’t move already open windows back to the correct monitor after sleep). - Reduce EDID collisions by plugging your monitors into different physical port types (e.g. one monitor on USB-C or DisplayPort and another on HDMI). Avoid DisplayLink hubs if you want reliable sleep/wake behavior.
- Last resort if macOS refuses to remember your layout: Back up and delete your
~/Library/Preferences/ByHost/com.apple.windowserver.displays.*.plistfile. Reboot your Mac, re-create your display layout (System Settings > Displays > Arrange) and sleep/wake your Mac a few times to see if it sticks.
Comparing the tools that fix this
The following tools each solve a different piece of this problem (display order after sleep or window layout after sleep). Choose the tool(s) that solve the specific problems you encounter on your desk.
| Tool | Fixes Swapped Monitor Arrangement? | Restores Window Positions After Sleep? | Restores Across Spaces? | Price & License | Best For |
|---|---|---|---|---|---|
displayplacer + sleepwatcher | Yes (CLI script on wake) | No | No | Free (open source) | Developers comfortable running Homebrew + ~/.wakeup scripts |
| BetterDisplay | Yes (extended display IDs) | No | No | Free tier; Pro $21.99 | Display tuning (HiDPI, virtual screens, XDR/DDC) + arrangement protection |
| Stay | No | Yes (automatic on display change) | Limited / varies | Free (Mac App Store) | Simple automatic window restore without paying |
| Moom 4 | No | Yes (saved layouts + display triggers) | Current Space / limited | $15 once ($8 upgrade) | Mature window snapping + custom saved layouts |
| Rectangle Pro | No | Yes (App Layouts) | Limited | ~$9.99 once (3 Macs) | Fast keyboard snapping + occasional saved workspaces |
| Universal Display Magnet (my app) | Yes (snap-flush editor + serial-number detection + auto-restore) | Yes (automatic snapshots + Workspaces) | Yes (Desktops & full-screen Spaces) | $9.99 once (3 Macs, direct download) | Fixing monitor arrangement, windows, Dock pinning & Universal Control in one app |
How the tools work in practice
Free CLI scripts (displayplacer + sleepwatcher)
If you want a free and open source solution and are comfortable using Homebrew and writing shell scripts then the combination of displayplacer and sleepwatcher is the way to go.
Install both tools with Homebrew:
brew install displayplacer sleepwatcher First, set up your monitor configuration the way you want it in System Settings > Displays. Then run the following command in the Terminal:
displayplacer list Scroll to the bottom of the output to find a command that looks like displayplacer "id:..." and copy it. If your monitors expose serial-based s... IDs, prefer using those as that will help make sure the monitors don’t swap positions when you sleep/wake your Mac.
Then put that command in a ~/.wakeup shell script with a sleep 3 before it so that your monitors finish waking up before the command gets run. Then run the following commands to make the script executable and start the sleepwatcher daemon:
chmod +x ~/.wakeup brew services start sleepwatcher sleepwatcher will trigger your .wakeup script every time your Mac wakes up from sleep.
Caveat: this won’t restore your window positions, just your monitor positions. If you have 2 identical monitors and they don’t have useful serial numbers, displayplacer still won’t be able to keep your monitors from swapping positions.
BetterDisplay for hardware tuning and display IDs
BetterDisplay is the most full-featured display configuration tool for macOS and is my go-to tool for tweaking hardware-level display settings that aren’t available in macOS itself, such as HiDPI scaling, creating virtual displays, setting brightness with DDC, switching the HDMI input on a monitor, and XDR brightness.
BetterDisplay has an advanced setting for Display Identification Method where you can choose to switch to extended display identifiers so that your Mac can differentiate between identical monitors even when they don’t have useful serial numbers.
Note that BetterDisplay is not a window restorer, so if you want to restore window layouts on wake, you’ll want to pair it with Stay or Moom.
Stay or Moom 4 if you only need window positions
If your monitors never swap positions left and right after sleep and you’re just frustrated with windows collapsing onto your MacBook screen when you dock and undock, then you might not need a display identification tool like displayplacer or BetterDisplay. In that case you only need a window restorer like Stay or Moom 4.
Stay is free on the Mac App Store and will automatically restore window sizes and positions for each display setup. Stay works well and has minimal overhead.
Moom 4 is a $15 one-time purchase ($8 upgrade if you already have Moom 3) that adds a bunch of window grid snapping and saved layouts that are triggered automatically when the display setup changes.
Both Stay and Moom 4 are only window restorers and not display ID tools so they will not fix the issue where your monitors swap positions left and right after sleep.
Universal Display Magnet for arrangement, windows, Dock pinning, and Universal Control
I made Universal Display Magnet because duct-taping BetterDisplay, Moom, and a ~/.wakeup script together just to get dual identical monitors to behave properly got old fast.
Universal Display Magnet is a one time purchase of $9.99 USD for 3 Macs and is distributed via direct download (not available in the Mac App Store). It requires macOS 14 or later running on either Apple silicon or Intel hardware.
Like the tools above, Universal Display Magnet uses the serial numbers reported by monitors to distinguish identical models. It includes a visual display arrangement editor with snap-flush alignment so you don’t have to guess which monitor is on the far left. When applying your display arrangement you’ll get a 15 second countdown to revert if it didn’t work as expected. When waking from sleep or reconnecting your dock Universal Display Magnet will automatically restore your saved layout.
When your display arrangement is restored, Universal Display Magnet will restore your windows from automatic snapshots it takes periodically and before sleep. You can also save named Workspaces that restore windows to their exact monitor, Desktop, and full screen Space.
Universal Display Magnet v0.5.0 added Local Dock Pinning. This solves the annoying issue of the Dock jumping between screens whenever your mouse cursor touches the bottom edge of your screen, without needing to turn off Displays have separate Spaces (which would cause you to lose per-monitor Spaces and menu bars). You can pin your Dock to any combination of monitors and use the Option key any time to pull the Dock onto whichever display your cursor is hovering.
You can also use Universal Display Magnet to align displays between multiple Macs running Universal Control. It will sync display arrangements and window layouts between all your Macs over encrypted LAN (no cloud, no account required, no analytics).
Universal Display Magnet includes Magnet-compatible window snapping and optional Scrolling Windows powered by Paneru.
Universal Display Magnet is not a replacement for BetterDisplay if you need HiDPI scaling, virtual displays, or hardware DDC control of brightness or inputs. Install both and run them side-by-side. If you prefer free open source command line / tiling tools, displayplacer handles monitor arrangement and AeroSpace provides automatic i3 style tiling across virtual workspaces.
Quick diagnostic checklist
- If identical monitors swap left and right after sleep -> fix display arrangement first (
displayplacer, BetterDisplay or Universal Display Magnet) - If your monitors stay in place but your windows pile up on your MacBook’s screen after sleep -> add a window layout restorer (Stay, Moom 4, or Universal Display Magnet)
- If your Dock jumps between monitors whenever your mouse touches the bottom edge of the screen -> keep “Displays have separate Spaces” turned on and pin your Dock (DockAnchor, DockLock, or Universal Display Magnet v0.5.0)
For step-by-step troubleshooting guides on fixing monitor arrangement (and checking whether your identical monitors expose distinct serial numbers to macOS), see Mac Monitor Arrangement Keeps Changing – How To Fix.
To fix windows moving after sleep, see Fix Mac Windows Moving After Sleep.




