Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Excuse me if this has been answered already, but I couldn't find any questions quite matching my issue.

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.

share|improve this question

13 Answers 13

up vote 32 down vote accepted

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:

    xrandr --output DVI-0 --primary --mode 1440x900

    Save this on your desktop as

  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

    Now run it:


    (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/ /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:


Now reboot and that should set the correct resolution on your lightdm log in screen.

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

share|improve this answer
Thanks! I use Leon's script mentioned below. – 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. – pthurmond 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

  1. log in
  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

Since I already had my monitors configured properly I just had to do step 3.

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.

share|improve this answer
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
Strangely, did not work for me (on Debian). What component would read the monitors.xml file? Some kind of settings daemon? – Joachim Breitner Oct 28 '13 at 10:13
Joachim, I just found this workaround in the bug discussion that I linked to. There's not a lot of explanation given on why/how it works and I didn't put much research into it. I guess it's the unity-greeter daemon. Could it be that you are using a Nvidia card? @aap Yes, I was also surprised to find an easy workaround after having tried all the other solutions given here without satisfactory results. I didn't test with multiple users. – Tobold Oct 28 '13 at 11:26
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. Brauer Jan 26 '15 at 20:32

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.

share|improve this answer

I use different displays connected to my HDMI ports (one on dock) and the laptop display. In order to resolve LightDM login resolution bug I've written a script beginning from what written in this topic. #

XCOM01=`xrandr -q | grep 'HDMI1 connected'`
XCOM02=`xrandr -q | grep 'HDMI2 connected'`
XCOM1=`xrandr --output HDMI1 --primary --auto`
XCOM2=`xrandr --output HDMI2 --primary --auto`
XCOM3=`xrandr --output LVDS1 --primary --auto`
# if the external monitor HDMI1 is connected, then we tell XRANDR to set up use it for login
if [ -n "$XCOM01" ] || [ ! "$XCOM01" = "" ]; then echo $XCOM1
# if the external monitor HDMI2 is connected, then we tell XRANDR to set up use it for login
else if [ -n "$XCOM02" ] || [ ! "$XCOM02" = "" ]; then echo $XCOM2
# if both the external monitors are disconnected, then we tell XRANDR to output to the laptop screen
else echo $XCOM3
exit 0;

Now the resolution is correct in the different situations, but the greeter panel occupies a space on the top-left of the screen equal to the previous wrong resolution!! What can I do?

share|improve this answer

For a multi monitor setup where you might disconnect your laptop and use without, here is a simple solution:



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:


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

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




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.

share|improve this answer

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).


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
        unset mode arg resolution;
share|improve this answer

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


and changed it to:


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.

share|improve this answer

“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.

share|improve this answer

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"

share|improve this answer
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

I've had similar problems, or even worse: Due to a KVM-switch (later on) between PC and monitor not all monitor resolution settings work. Linux: KUbuntu 14.04-LTS (german edition). First, /etc/lightdm/lightdm.conf did not exist - got it after changing default setup in KDE-system-setup: system management / login screen. Second, modified this file:

# --- setup of resolution using 'xrandr', see 'man xrandr' or 'xrandr help' and try command on a console
display-setup-script=xrandr --output HDMI-0 --primary --mode 800x600
# display-setup-script=/usr/share/lightdm/
# --- Num-Lock ON - a test --- preparation: apt-get install numlockx 
greeter-setup-script=/usr/bin/numlockx on

Additional info: As grub menu should appear, too, I changed /etc/default/grub, adding the line

share|improve this answer
Is this supposed to be an answer? Because it looks a bit like a problem description to me. – David Foerster Dec 29 '15 at 23:51

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, 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);
            local   resolution=${1:-"$(get_resolution $display)"};

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

            if [[ $display == $lvds ]];
                    xrandr --output $display --off;
            elif [[ -n $mode ]];
                    xrandr --output $display $arg $mode;

share|improve this answer

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

share|improve this answer
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 removed it :( – Leon Dec 8 '13 at 20:24

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.