Modify screen resolution or dpi in display manager like gdm or lightdm

If you have a screen with a large resolution (for example 4k) or you have a high DPI (HiDPI) screen, you will know that the display manager uses a lower resolution or a wrong DPI setting.

The solution is very easy. As gdm or lightdm also have a normal user account with normal home directory. So you can just copy your correct monitors.xml to the home directory of your display manager. For gdm this would be:

sudo mkdir -p ~gdm/.config
sudo chown gdm:gdm ~gdm/.config
sudo cp -a  ~/.config/monitors.xml ~gdm/.config/
sudo chown gdm:gdm ~gdm/.config

After reboot you will see the correct screen resolution.

This is especially useful on HiDPI changes, because GNOME Shell in Manjaro (ArchLinux) makes all windows small on screen lock, so that you have to resize them after relogin.