Display settings are not saved after monitors wake from sleep

I just got a new System76 Thelio with an AMD 6600XT running Ubuntu 20.04. I have 3 4k displays with one in landscape in the center and a portrait monitor on either side. All displays are using native 4k resolution with no scaling.

When the displays go to sleep and wake back up, the scaling is turned up to 200% on all of them, none of them are in portrait, the refresh rate of the center monitor changes from 60hz to 30hz, and all of the windows have been moved and resized.

If the computer just reboots with the settings set properly there are no issues, but for some reason sleeping the displays and waking them up causes complete chaos.

I had previously experienced a similar issue on Xubuntu 18.04 on a Lenovo laptop which had an nVidia Quadro P3000. At the time I attributed it to nVidia being the issue…but now with an AMD GPU I’m experiencing the same awful behavior.

It looks like there are a handful of related threads out there for different DE’s:

Neither of those threads have working fixes.

I can’t be the only person out there running multiple portrait displays in Linux…this issue is would making working unbearable by having to re-set all my display settings and then re-arrange all my windows every time the displays go to sleep after 15min of inactivity.

A workaround of never having them go to sleep is not acceptable as it would burn out the displays faster and use more energy.
A workaround of running a command to set the settings automatically may be possible, but if all of the windows move around and have to be moved back, then it’s not a great workaround.

Has anyone out there had this issue and found a good workaround or possibly a fix?

Here is my xrandr output:

Screen 0: minimum 320 x 200, current 8160 x 3840, maximum 16384 x 16384
DisplayPort-0 connected primary 3840x2160+2160+1128 (normal left inverted right x axis y axis) 600mm x 340mm
   3840x2160     60.00*+  30.00  
   2560x1440     59.95  
   1920x1200     60.00  
   1920x1080     60.00    59.94  
   1600x1200     60.00  
   1680x1050     60.00  
   1600x900      60.00  
   1280x1024     60.02  
   1440x900      60.00  
   1280x800      59.81  
   1280x720      60.00    59.94  
   1024x768      60.00  
   800x600       60.32  
   720x480       60.00    59.94  
   640x480       60.00    59.94  
DisplayPort-1 connected 2160x3840+0+0 left (normal left inverted right x axis y axis) 600mm x 340mm
   3840x2160     60.00*+  30.00  
   2560x1440     59.95  
   1920x1200     60.00  
   1920x1080     60.00    59.94  
   1600x1200     60.00  
   1680x1050     60.00  
   1600x900      60.00  
   1280x1024     60.02  
   1440x900      60.00  
   1280x800      59.81  
   1280x720      60.00    59.94  
   1024x768      60.00  
   800x600       60.32  
   720x480       60.00    59.94  
   640x480       60.00    59.94  
DisplayPort-2 connected 2160x3840+6000+0 right (normal left inverted right x axis y axis) 600mm x 340mm
   3840x2160     60.00*+  30.00  
   2560x1440     59.95  
   1920x1200     60.00  
   1920x1080     60.00    59.94  
   1600x1200     60.00  
   1680x1050     60.00  
   1600x900      60.00  
   1280x1024     60.02  
   1440x900      60.00  
   1280x800      59.81  
   1280x720      60.00    59.94  
   1024x768      60.00  
   800x600       60.32  
   720x480       60.00    59.94  
   640x480       60.00    59.94  
HDMI-A-0 disconnected (normal left inverted right x axis y axis)

Update:
I turned off the lock screen setting for when displays go to sleep. When I tested it (once) only the Firefox Developer Edition window was moved when I woke the screens back up. The screen settings appear to have remained in place.

I have now also set gsettings set org.gnome.settings-daemon.plugins.xrandr active false to see if that will disable reacting to the screens sleeping/waking from gnome/xrandr.

I also created a script to put my displays back to the way they are incase this happens again:

xrandr --output DisplayPort-0 --pos 2160x1319 --primary --rate 60.00;
xrandr --output DisplayPort-1 --pos 0x0 --rotate-left --rate 60.00;
xrandr --output DisplayPort-2 --pos 6000x0 --rotate right --rate 60.00;

The script does work although I have not been able to test it when the scaling gets messed up.

If I don’t post another update, it’s because the above 3 solutions are enough of a workaround for me. Hopefully this issue gets resolved in future gnome/ubuntu updates so that workarounds like these are not needed anymore.

It’s a shame some of those threads go back 7+ years with no real fix when coming from macOS I did not have these problems.

1 Like

Unfortunately I have to post another update because all of the above fixes do not work perfectly. When the monitors go to sleep (after 15min) they sometimes don’t all come back to life, get weird resolutions, have their refresh rate set to 30hz, will overlap each other, etc.

Sometimes running my xrandr script from the last comment twice works. Sometimes I have to go into the display settings, set a random change, and then click “revert” to get them to work.

So I’m at a loss at this point. I hope someone else can find an issue for the various window managers out there facing this issue (seems like all of them).

I’ll continue to update this thread over time if I find any fixes or workarounds or maybe if a window manager out there solves this, I’ll try switching to it.

I’m afraid I can’t offer to you a fix but I do think it’s telling that in each of our cases, for unexpected display output behaviour in Linux each of us resorted to overriding the DE’s failures with xrandr scripts.

under gnome (ubuntu) my experience is it will reset location and orientation of all the displays when the outputs change (it also doesn’t like overlaps). But I don’t experience application window locations reset, even though I’ve seen it.

That, to speculate could be something like one of the monitors is not waking fast enough but if so I don’t know it could be overriden.

I’d certainly not be above trying setting the ~/.config/monitors.xml file read only (once configured in settings).

This post helped me find the root of the issue. I have three monitors and just recently the issue started happening when I’d wake the computer up from sleep. The only thing I can think of that did before this happened, was allow Ubuntu to run updates.

When I examined the ~.config/monitors.xml file I saw that it had six display entries instead of just three. I suspect that something having to do with the updates had made some new, weird entries in the monitors.xml file. I kept the first three and deleted the rest then saved the file and rebooted.

When the machine came back up, the monitor placement was not perfect (I suspect I didn’t keep the correct three entries) but I rearranged them in the settings / displays UI and went about my day.

The next day when I woke the machine, the monitors had stayed put overnight.

While this may not the answer for everyone, the first thing I’d do is check ~.config/monitors.xml and make sure you don’t have any extra entries in it.

1 Like