Window positions restore after multi monitor sleep/wakeup
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I have a multi monitor setup with 3 4k monitors in portrait mode. When they go to sleep, they are reported disconnected from the HDMI/DP ports. When they subsequently wake up, the windows are sometimes rearranged onto different monitors. Not always, but often enough. This is very annoying and I need it fixed. I researched and it doesn't look like there is a ready solution. The computer itself isn't suspended, just the monitors.

This doesn't seem to be hardware dependent, it happens with RX 570, RX 5700 and Ryzen iGPU. It happens on AMD and Intel CPUs. It happens with DisplayPort or HDMI. It happens on Ubuntu 20.04, Ubuntu 18.04. It doesn't even look like other operating systems designers thought about this, as the same thing happens when I run Catalina on the same hardware (hackintosh), although I recall it behaving differently when I turned on the setting which said something like "join the monitors into one".

It happens with Gnome/Unity and KDE Plasma, it happens with or wayland.

I suspect some of it has to do with the monitors being in portrait mode (portrait left to be specific) or the order the monitors wake up (the monitors are identical models), but I'm not sure. I tried changing the DPMS mode (sleep/standby/off) but it doesn't seem to make any difference, the monitors react to all of them the same way, by turning off the backlight and disconnecting from the port.

Examples of potential solutions that I would accept:

  1. a window manager that can handle this on its own, preferably one that supports wayland and is easy to install on ubuntu 20.04
  2. a configuration setting that will fix it
  3. a script that listens on the monitor connect/disconnect signals, or screen lock/unlock signals and saves and restores the positions
  4. a patch for a windows manager / x / wayland / ... to fix/prevent/workaround this

My guess is that number 3 has the best likelihood of being successful, so my recommendation is to focus on that approach unless you have a better idea.

Examples that I won't accept:

  • use an OS other than linux
  • leave monitors on or turn computer off (this would technically fix it but isn't a solution for other reasons)
  • buying different monitors on the off chance it may help. Assume this wouldn't work.
  • using an nvidia GPU on the off chance it may help. Assume this wouldn't work.

Solution described here:, disabling reactions to monitor hotplug events, seems to work for me so far:

gsettings set org.gnome.settings-daemon.plugins.xrandr active false


Crowdsource coding tasks.

2 Solutions

I use i3 and it has layout management which lets to fix windows on their places by window class or app name. The same way your window manager must have layout management API which can control window placement maybe with Python, Tcl/Tk, or Lua. I can't point you to KDE tools as I use i3 see above.

Also, I don't think that ready-to-use tool will be usable for you, as in most cases we need to have more control then predefined implementation allows us.

The starting point maybe this:

(Not a full solutiion and so I don't expect the bounty, but maybe something that can guide you in the right direction)

Have you looked at xrandr/arandr? xrandr is a command line program that can rearrange your monitors and arandr is a GUI program for the same thing. If you file -> save as in arandr you can generate an xrandr script. This isn't fully automatic but running ~/ each time is a lot less work than manually fixing them.

xrandr can't move windows as far as I know. The monitor position and rotation aren't the problem, they do get restored correctly.
PeterSurda over 1 year ago
View Timeline