Apply display settings to all user accounts?

I spent some time getting my settings correct for multiple monitors, and that is working fine when I am logged in, but is not right at the login screen or for other users.

How do I set the display settings globally for all users and the login screen?


Depending on the way you've set up your system, it might be as easy as copying the monitors.xml file from the correctly set-up user to all users:

To test this for one user:

cp --preserve=timestamps /home/CorrectUser/.config/monitors.xml /home/TestUser/.config/

then log off TestUser if already logged in, log back on and see whether everything is correct.

The command for all users:

cp /home/CorrectUser/.config/monitors.xml /tmp/
for szUser in /home/* ; do sudo cp --preserve=timestamps /tmp/monitors.xml $szUser/.config/ ; done

The command for the login screen:

sudo cp --preserve=timestamps /home/CorrectUser/.config/monitors.xml /var/lib/lightdm/.config/

The command for all future users¹:

sudo mdkdir -p /etc/skel/.config
sudo cp --preserve=timestamps /home/CorrectUser/.config/monitors.xml /etc/skel/.config/

Note¹: All users you'll be creating in the future


To set your screen configuration for every user on log in (this will not change the configuration on the log in screen), you can create a .desktop file in /etc/xdg/autostart

How to do that

  1. find out the name of the screen you'd like to be rotated by running xrandr. It will output a number of lines, among thos a few lines looking like:

    VGA-0 connected
    

    This gives you information on the names of the connected screens.

  2. Pick the one you want to have rotated, in my example below VGA-0
  3. Create a launcher with (e.g.) gedit:

    sudo -i gedit /etc/xdg/autostart/set_screens.desktop
    

    Paste the text below into the file:

    [Desktop Entry]
    Name=set_screens
    Exec=/bin/bash -c "sleep 10&&xrandr --output VGA-0 --rotate left"
    Type=Application
    

    replace in the line:

    Exec=/bin/bash -c "sleep 10&&xrandr --output VGA-0 --rotate left"
    

    The string: VGA-0 by your (rotated) screen's name.

Important notes

  • In the line

    Exec=/bin/bash -c "sleep 10&&xrandr --output VGA-0 --rotate left"
    

    I included a sleep 10. That is because sometimes, xrandr commands break if they run too early, before the desktop is "finished" loading. Possibly you need to increase the break, or you could try leaving it out. In the command, as it is, the screen rotates after 10 seconds after log in of any user.

  • The command:

    xrandr --output VGA-0 --rotate left
    

    rotates the screen left, no need to say that if you'd like another type of rotation, you can choose either left, right, normal, inverted (see also here).

Explanation

You can run commands on startup (actually log in) by placing a .desktop file (launcher) in ~/.config/autostart. This will only run the launcher for a single user. If you do the same, but place the launcher in /etc/xdg/autostart, the command runs whenever any user logs in, unless a specific user disables the launcher for him or her in Dash > Startup Applications

Additionally, you can simply copy your local ~/.config/monitors.xml file to /var/lib/lightdm/monitors.xml to also make the settings work on log in screen.

Imo the combination of this, and the solution above (a launcher in /etc/xdg) is the easiest solution to achieve exactly what you want for both the login screen and (any) user. Also, the solution of a launcher in /etc/xdg is (very) easily reversed or changed in case you'd need to make another setup, without editing many files on (each) user's level, since both the user's settings and the login screen are managed for all users at once in two simple files.


Just wanted to add a comment for anyone finding this struggling with a similar issue. I was stuck with resolution of my old monitor (1280x1024) every time I log in, but the login screen and guest user login use the correct default 1680x1050.

I've read a lot of posts over the last four months looking for an answer, reading up on xorg.conf, monitors.xml, lightdm and xrandr and other suggestions - but some config changes are complicated and carry the risk of breaking the display entirely, so I ended up using the gui to change the monitor setting manually every login.

Today I did a grep for the old resolution in my .config folder.

grep -HrnIF '1280' .config | less

First result was ~/.config/autostart/xrandr.desktop file containing this,

Exec=xrandr -s 1280x1024 -r 75

so I just moved the file out of there. And bingo, I log in and get the default 1680x1050 resolution.

It took me a few hours of searching and I couldn't find a close enough answer, so posting here in case it's useful to someone.