Monitor settings get written to ~/.config/monitors.xml. If this file is messed up (e.g. through Nvidia drivers) it can be deleted and it will be created again when the display settings are run.

The settings file then needs to be copied over to gdm3 or whatever the displaymanager is:

sudo cp ~/.config/monitors.xml /var/lib/gmd3/.config

It may be useful to set up openssh-server before that, in case gdm3 crashes at the next login and the login isn’t possible, even via tty (CPU performance may be at 100% and the machine does not react). In this case ssh into the machine from another machine and restart the displaymanager service:

`sudo service gdm3 stop`

then

`sudo service gdm3 start`