On the odd occasion, usually after incorrectly restarting my computer, my login screen resolution is not the default 1440x900, but I think 1600x900. Now, I have this monitor that's really bad at handling resolutions it's not designed to handle, and will show a silly "wrong resolution" box jumping around the screen.

Is there any way to make the login screen load a 1440x900 resolution no matter what? I'm running Ubuntu 11.10 with Unity and LightDM.

You can make a script for this (source LightDM Resolution).

1. Firstly we need to find out what your monitors identifier is. Open up a terminal, start typing terminal in your unity dash to see the option or press Ctrl+Alt+T
2. Type/copy this command to show your display details:

xrandr -q


If you only have one monitor you will see a line in the output like the following (probably with some different values, its the identifier at the start we are after):

DVI-0 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 473mm x 296mm


The screen identifier is DVI-0 in this case

3. Open up your favourite text editor, lets use gedit for this example, press Alt+F2 and type gedit

4. Type/copy this in:

#!/bin/sh
xrandr --output DVI-0 --primary --mode 1440x900


Save this on your desktop as lightdmxrandr.sh

5. You may want to test the script before we put it into practice. Back in the terminal navigate to where we just saved it:

cd ~/Desktop


Now we need to make it executable:

chmod a+rx lightdmxrandr.sh


Now run it:

./lightdmxrandr.sh


(If your screen automatically auto-corrects after log in you probably won't see a difference so you may want to use a test resolution that is different but you know works while testing)

6. Now lets move the little script we made:

sudo mv ~/Desktop/lightdmxrandr.sh /usr/share/.


If you don't use sudo you may get a permission error (I use this folder out of personal preference)

7. We need to now run this in lightdm, navigate to the correct folder:

cd /etc/lightdm

8. Open up the lightdm conf file:

sudo gedit lightdm.conf

9. Now add the the instruction to run your script after the last line and save:

display-setup-script=/usr/share/lightdmxrandr.sh


(these instructions might look long but they don't take long at all)

• Thanks! I use Leon's script mentioned below. askubuntu.com/a/88882/28071 – beanaroo Mar 2 '12 at 13:21
• That's a nice script, think I'll store that for future use! – captain_G Mar 2 '12 at 21:07
• Unfortunately this just breaks things in Ubuntu 13.04. Probably because they have been making some massive changes to the OS. – Patrick Sep 23 '13 at 15:24
• Also doesn't work with Ubuntu 13.10 + NVIDIA driver 319: The script is executed but the resolution doesn't change - probably because the NVIDIA driver overrides it. – speakr Nov 5 '13 at 8:12
• I think it should be chown root:root also? – Aquarius Power Oct 12 '14 at 19:38

I found a very simple workaround that works perfectly for me running 13.04. (update: now 13.10) on a laptop with a 24" external screen that is not permanently connected.

I'll just copy from here

2. use xrandr or the Displays control utility to configure your monitors how you'd like them to be configured in the login screen
3. copy ~/.config/monitors.xml to /var/lib/lightdm/.config

Some other answers given here worked for me but only in a specific scenario while running risk of an unusable system in other scenarios (LOW GRAPHICS MODE ERROR). For example with the external monitor permanently connected (accepted answer by @captain_G) or with always the same device connected to the output used for the external monitor (script by @Axlrod). It seems that @MarcoV's answer is the most generic solution, however it does still involve scripting rules.

• Much simpler than the other answers... I wonder why it doesn't have more votes. Well, it has mine. – aap Oct 27 '13 at 14:28
• Then again, although it does help the login screen, it would be nice if other users didn't have to set up the display resolution again. – aap Oct 27 '13 at 18:41
• Rather than copying the file, create a link to it so that it's automatically updated whenever you change your screen settings: $sudo ln ~/.config/monitors.xml /var/lib/lightdm/.config/monitors.xml (No, symbolic links DO NOT work.) – Nathan J.B. Jan 26 '15 at 20:32 • Which application writes/updates monitors.xml? I'm using XFCE and this file is 2 years old and completely outdated. I can't find a similar file. – scai Oct 15 '15 at 14:24 • This is the correct approach as opposed to creating a script to change resolutions. .config/monitors.xml can support multiple monitor configuration (i.e. your setup at work with a dock and 2 monitors vs your setup at home with no dock and 1 external monitor). Creating a manual script to set the resolution would be relatively more complex to do.| – Iyad K Dec 20 '18 at 13:20 You can instead of creating script, just add to file /etc/lightdm/lightdm.conf a line like this: display-setup-script=xrandr --output default --mode 1280x720  Before inserting make sure that command works, because with wrong command, lightdm will not start. • Hi, your xrand commands says : warning: output default not found; ignoring – SebMa Apr 27 '18 at 13:29 • @SebMa You have to use the correct output name! – Ken Sharp Jul 5 '18 at 15:59 For a multi monitor setup where you might disconnect your laptop and use without, here is a simple solution: run: xrandr  Get the devices you are using laptop is usually LVDS1, and for me I have a DP2 (displayport 2) it could be HDMI1 or anything else, just find the ones with resolutions listed next to them. Create this small bash file: #!/bin/bash mode="$(xrandr -q|grep -A1 "DP2 connected"| tail -1 |awk '{ print $1 }')" if [ -n "$mode" ]; then
xrandr --output LVDS1 --off
xrandr --output DP2 --primary --mode 2540x1440
fi


Replace LVDS1 with your laptop monitor connection.

Replace DP2 with your external monitor connection.

Place bash script in /usr/bin/local/

chmod +x the script

edit /etc/lightdm/lightdm.conf

display-setup-script=/path/to/my/script


Reboot.

The resolution change will only happen when you are actually at that display now.

If you have multiple places with different monitors / resolutions on same connector you will have to put more intelligence in your bash script.

Just little bit improved the above Axlrod's script.

All you need to do is specify which monitor to use primary, and which is your laptop display(LVDS).

#!/bin/bash
LVDS="LVDS-0"
PRIMARY="VGA-0"

function get_displays()
{
xrandr -q | grep connected | awk '{print $1}' } function get_resolution() { [[ -z "$1" ]] && return 0 || xrandr -q | grep -A1 $1 | tail -1 | awk '{print$1}' | grep -e "^[0-9]"
}

for display in $(get_displays); do resolution=get_resolution$display

[[ $display ==$PRIMARY ]] && arg="--primary";
[[ -n $resolution ]] && mode="--mode$resolution";

if [[ $display ==$LVDS ]]; then
xrandr --output $display --off elif [[ -n$mode ]]; then
xrandr --output $display$arg $mode fi unset mode arg resolution; done  sudo gedit /usr/share/X11/xorg.conf.d/52-myres.conf  then in the file: Section "Monitor" Identifier "VGA1" Option "PreferredMode" "1152x864" EndSection  Save and exit. The values were obtained from command xrandr -q. VGA1 is the name of my connector and 1152x864 is the name of the resolution. This works for Xubuntu 16.04. It sets a preferred resolution and for me it let me set the resolution of the login screen, instead of having it default to the highest resolution supported. Modified from answers here • After install open-vm-tools and open-vm-tools-desktop, copying monitors.xml to /var/lib/lightdm/.config was no longer working for me. Specifying the preferred resolution like this fixed it for me. – jropella Jul 30 '17 at 6:32 What I've found to be useful was a post on the Ubuntu guide website . I tried so many things in Ubuntu 11.10 and even tried to use simply GNOME Classic. The resolution was always 1024x768 and when I manually set it to 1440x900 it was "virtual", I mean I had to scroll with the mouse to explore the entire desktop that was beyond the real screen dimensions. In the Terminal I ran this command: sudo gedit /etc/default/grub  The text editor can take a while to load. Once it loaded, I edited the line GRUB_GFXMODE=1024x768  and changed it to: GRUB_GFXMODE=1440x900  Remember to run update-grub to apply the changes. After that I tried to reinstall VESA drivers (in this computer I have a GeForce 260 GTX). I know that the better way is to use Nvidia official drivers, but using them the problem was always the same... Sure, I think, now performance will be worse. So, checking Nvidia X Server Settings panel I verified that my resolution was added and, switching to it, it made the screen in the right look. Actually I'm using Ubuntu 11.10 but in GNOME Classic. I'm a newbie of Linux so hope I've written decent things. Don't muck with scripts or configuration files that have the possibility of rendering your login screen unusable! Instead, login and set your preferred screen settings*, then run this command: sudo ln ~/.config/monitors.xml /var/lib/lightdm/.config/monitors.xml  Your login resolution will now always reflect the settings of the user you're currently signed into. *Don't forget to click "Apply" • This works but it is secondary. It does a normal load in the max resolution and then switches to your settings. How can you make it load the correct resolution to start? – Goddard Dec 4 '15 at 3:58 Axelrod's script is somewhat defective, as a grep for 'connected' grabs all the 'disconnected' displays too...not what we want... Moreover, using grep with awk and tail, etc...is wastefully circuitous, and I'd suggest as follows hereupon. Additionally, in get_resolution we change the return code to 1, since a return code of zero is usually indicative of a lack of errors, thus we use 1 if the first parameter is absent. In conclusion, by instantiating the main part of the script a function, it can be sourced in and executed at any further time if need be in a function library as well as gaining the usage of local variables, which do not need to be unset. function get_displays() { xrandr -q | awk '($2 == "connected") {print $1;}' }; # the "\" and c/r were added for readability on this website # I do not have them in my code variant that I use. function get_resolution() { [[ -z "$1" ]] && return 1;
xrandr -q | \
awk -v display="$1" '($1 == display && $2 == "connected") {getline; print$1;}';
};

function setup_displays()
{
local   primary=${2:-"VGA-0"}; local lvds=${3:-"LVDS-0"};

for display in $(get_displays); do local resolution=${1:-"$(get_resolution$display)"};

[[ $display ==$primary ]] && local arg="--primary";
[[ -n $resolution ]] && local mode="--mode$resolution";

if [[ $display ==$lvds ]];
then
xrandr --output $display --off; elif [[ -n$mode ]];
then
xrandr --output $display$arg \$mode;
fi;
done;
};

setup_displays;


This is how I got it working in Xubuntu 16.04.

You need to obtain along string for the desired resolution. This is within the result of the command:

xrandr --verbose


Now pick the part with the resolution you want. It will look something like:

1152x864 (0xa6) 108.000MHz +HSync +VSync
h: width  1152 start 1216 end 1344 total 1600 skew    0 clock  67.50KHz
v: height  864 start  865 end  868 total  900           clock  75.00Hz


From the data above you should get the string 108.000 1152 1216 1344 1600 864 865 868 900 +HSync +VSync.

To find the name of your output, find a line similar too:

VGA1 connected 1152x864+0+0 (0xa4) normal (normal left inverted right x axis y axis) 306mm x 230mm


Here my output is named VGA1.

Now create script:

sudo gedit /usr/share/lightdmxrandr.sh


Then in the file write the following:

#!/bin/sh
xrandr --newmode "1152x864_75.00"  108.000  1152 1216 1344 1600  864 865 868 900 +HSync +VSync
xrandr --output VGA1 --mode 1152x864_75.00 --pos 0x0 --rotate normal


Save and close file. Make script executable:

sudo chmod a+rx /usr/share/lightdmxrandr.sh


Create a config file to call the script just created.

sudo gedit /etc/lightdm/lightdm.conf.d/00-myres.conf


inside this file enter:

[Seat:*]
display-setup-script=/usr/share/lightdmxrandr.sh


Save and close file. Restart and hopefully the resolution you chose will be at your login.

In practical terms this is the only way that worked for me, even though re-creating existing resolutions is not logical.

note

An alternative way to get the long resolution string is the program cvt. To get a string for resolution 1152x864, refresh rate 75.00:

cvt 1152 864 75


This gave me a slightly different resolution than my desktop resolution, and is the reason I did not include the method in the main answer.

If you're using LightDM's GTK greeter then you can run xrandr -q to find the names of your monitors then edit /etc/lightdm/lightdm-gtk-greeter and set the property active-monitor as described in the comments inside that file. This property can take multiple, ordered values including #cursor for the monitor that currently shows the mouse cursor.

i like to attach my script that configures the monitors to one of the multimedia keys on my keyboard that i don't otherwise use. currently i have the button labeled 'windows media center' force my displays into their preferred configuration. this way if you are flying blind and your monitors aren't syncing to the desired resolution, just mash the hot key and all is fixed.

“Preferred Screen Modes” might be the Problem

I assume that your monitor reports the high screen resolution as being preferred. Now you would like to override this default preference. See my answer to a very similar question for details on how this can be done.

I had the opposite problem: I always got a lower screen resolution (1280x1024) than the one I wanted (1600x1200). The fix I have found (and described in the linked answer) will hopefully be applicable analogously to your problem, though.

• Whoever voted my answer down, could you please add a note on why you think this answer is not useful? – Chriki Oct 4 '16 at 10:43

I had the same problem on my MacBook Pro mid-2014 (11,1) running Xenial. I have tried all the aforementioned solutions in various forms, but invariably would get X going into failsafe low-graphics mode (but displayed in the very resolution I wanted it to set as default no less.

After much wrangling over the forums and googling, turns out that I had forgotten the simplest and default potential solution: nomodeset. That fixed the problem.

TL;DR: Don't forget to try nomodeset! Esp. on a MacbookPro 11,1.

I've created this script to make it more dynamic (multiple workspaces / different monitors).

Only annoyance: when you log in from lightdm, the screen still flashes like it wants to change resolution :s

• Paste was not found. – Tobold Aug 13 '13 at 8:13
• Indeed; if you still have a local copy of the script please consider re-uploading it. – wchargin Sep 25 '13 at 13:18
• I've uploaded the script to github. I don't know why paste.ubuntu.com removed it :( – Leon Dec 8 '13 at 20:24