Apply display settings to all user accounts?

8,343

Solution 1

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 mkdir -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

Solution 2

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.

Solution 3

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.

Solution 4

for Ubuntu 21.10 the display manager is gdm3 and the command to change the login screen resolution is

sudo cp -v ~/.config/monitors.xml /var/lib/gdm3/.config/

the other existing user can be set with

for u in /home/*
do
   if [ "$u" != "$HOME" ]
   then
       sudo cp -v ~/.config/monitors.xml "$u/.config"
    fi
done

and future users

   sudo mkdir -v /etc/skel/.config/
   sudo cp -v  ~/.config/monitors.xml /etc/skel/.config/

Note: the -v is optional

NB: don't bother with /root the root user as you should NEVER login as root in the GUI it is very dangerous

Share:
8,343

Related videos on Youtube

mirams
Author by

mirams

Updated on September 18, 2022

Comments

  • mirams
    mirams almost 2 years

    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?

  • mirams
    mirams about 9 years
    That might work - changing the settings 10s after login, but I'd prefer to know where they are set to start with and change them for everyone (and the login screen, which is currently sideways).
  • Jacob Vlijm
    Jacob Vlijm about 9 years
    I already suggested it in the comments (and in my answer earlier, but rolled back), but OP mentioned it was not sufficient. This does only work for the log in screen :) It also does not work for new users unless you copy them again to those users.
  • Fabby
    Fabby about 9 years
    @JacobVlijm: Read again... Mine is for log-in screen and all users... :P (leaving it in there as a comment below this by the OP that it doesn't work would warn other posters from typing all that a third time) >:-)
  • Jacob Vlijm
    Jacob Vlijm about 9 years
    I didn' t suggest copying the file to all users, because of this: I'd like a solution that applies settings to all user accounts (and future ones), and also makes the login screen look right. adding to /etc/xdg seems to be the only trick that does that to new users as well.
  • Fabby
    Fabby about 9 years
    @JacobVlijm: ah, missed that one! (Added solution for that as well) ;-)
  • mirams
    mirams about 9 years
    This is best answer yet - sets all the monitors up correctly, and works immediately for the guest user too. As a bonus - is there a way to also copy the "Launcher Placement" setting from the Display Settings GUI too? On my user it is just on one monitor, but on both for new/guest user.
  • Fabby
    Fabby about 9 years
    I'm glad as I'm currently travelling so had no way to test this out... ;-) The launcher is a unity setting and is hidden somewhere else and as I don't have an additional monitor to test on, you'll have to drop by the AU General Chat Room so we can test things out together... An upvote for the answer so far would be nice! :-)
  • Fabby
    Fabby about 9 years
    Why would someone downvote this?
  • nixpower
    nixpower about 9 years
    It'd be great if you could try this out, I'm interested in seeing if this will work for you.
  • WinEunuuchs2Unix
    WinEunuuchs2Unix over 7 years
    Welcome to Ask Ubuntu. Thanks for sharing your four months (elapsed time) of research.
  • MattB
    MattB over 7 years
    Reading this again I think I possibly created that xrandr.desktop file two years ago to get around Ubuntu always defaulting to the 'Goldstar' basic monitor settings, and that was probably a compatibility issue with my video card.
  • Andrew Bate
    Andrew Bate over 2 years
    Is it necessary to use the --preserve=timestamps flag? For me it works without the flag. Are there cases where --preserve=timestamps is required?
  • Admin
    Admin about 2 years
    Unfortunately the accepted is grossly outdated, this should be the new accepted answer.