Linux – Stop display settings changing when turning off DP monitors on Linux Mint

displayportlinux-mintnvidiaxorg

I have Linux Mint Cinnamon 18.3 running with the proprietary drivers from Nvidia. The automatic display detection is great for setting up (way easier than the old days!) but as DisplayPort disconnects monitors when they're turned off, it's moving my windows around on my 3 display setup.

Is there any way to take a snapshot of the currently detected configuration and lock it in xorg to stop things changing and moving my windows around?

Alternatively, is there any way to tell the proprietary driver to ignore power states for the monitor? I'm unaware of the specifics of the DP protocol so not sure if this is an issue.

I had to disable DPMS/ sleep mode for my monitor as it kept crashing on resume so the only other option I have is to leave my monitors on all the time which will waste a lot of power.

Happy to share any configs etc but as it's all auto-detected I wasn't sure that would be much help.

Best Answer

In most cases, the RandR extension is used to configure display settings. Therefore, I will focus on it in this answer. So this answer may not apply if you're using Wayland, the proprietary NVIDIA drivers without DRM (Direct Rendering Manager) kernel mode setting enabled or have disabled the RandR extensions. If so, calling xrandr should result in an error instead of printing the current display configuration.

While xrandr does not change the display configuration if you unplug a monitor, your desktop environment does this. Technically, the desktop environment is implementing an xrandr client which is handling the XRRScreenChangeNotify event and updating your display configuration when a monitor is disconnected.

Depending on your used desktop environment, you can disable this behavior:

Gnome till 3.1.3:

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

This option was to be removed in newer versions. Seems to be handled by Mutter now.

Cinnamon:

Copy /etc/xdg/autostart/cinnamon-settings-daemon-xrandr.desktop to $HOME/.config/autostart. Then append the line Hidden=true to the copied file.

Cinnamon before 3.4:

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

Mate Desktop:

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

KDE

kscreen is managing the display settings in the KDE Plasma 5 desktop. There seems to be no way to disable the auto-plug behavior with a configuration setting. However, you can kill the daemon which is responsible for it /usr/lib/kf5/kscreen_backend_launcher to prevent any further changes to your display configuration. Note: The daemon will be restarted when you're launching the KDE display settings.

Related Question