Forcing lightdm to Use a Specific Resolution

This morning I was debugging a problem in unity-greeter and I suspected that it might be related to the resolution of the system I was using. Since I was live booting it was a pain to make changes, mainly because I didn’t have all my standard tools (or web access). I ended up messing around with xorg.conf files for awhile, without much success (this reminded me of college, but not pleasantly). After some other searches, I ended up settling on this method:

For this example, I wanted a resolution of 1024×600.

  1. Login to my system
  2. Open a terminal and run cvt 1024 600
  3. Copy the resulting output, minus ModeLine portion
  4. mfisch@caprica:~$ cvt 1024 600
    # 1024x600 59.85 Hz (CVT) hsync: 37.35 kHz; pclk: 49.00 MHz
    Modeline "1024x600_60.00"   49.00  1024 1072 1168 1312  600 603 613 624 -hsync +vsync
  5. Run xrandr –newmode
  6. mfisch@caprica:~$ xrandr --newmode "1024x600_60.00"   49.00  1024 1072 1168 1312  600 603 613 624 -hsync +vsync
  7. Run xrandr –addmode LVDS 1024x600_60.00. (Note that there are several displays that xrandr shows, I wanted to change my main laptop display, LVDS, you may want to change another. Run xrandr without arguments to see all the displays.)
  8. Run xrandr –output LVDS –mode 1024x600_60.00
  9. If that switches your resolution and looks right, then lets make it permanent.
  10. Edit: /etc/lightdm/lightdm.conf, add this line (note you can choose a different path:
  11. display-setup-script=/usr/bin/lightdmxrandr
  12. Make a new file called /usr/bin/lightdmxrandr, make it a shell script that just executes lines 4, 5, and 6 from above
  13. #!/bin/sh
    xrandr --newmode "1024x600_60.00"   49.00  1024 1072 1168 1312  600 603 613 624 -hsync +vsync
    xrandr --addmode LVDS 1024x600_60.00
    xrandr --output LVDS --mode 1024x600_60.00
  14. Make /usr/bin/lightdmxrandr executable, logout, and restart lightdm (sudo initctl restart lighthdm)
  15. Enjoy your new resolution!

Here are the two links that helped me piece this together:

How change display resolution settings using xrandr
How can I make xrandr customization permanent?

Tagged , ,

4 thoughts on “Forcing lightdm to Use a Specific Resolution

  1. Abhijit says:

    Useful post. Just one addition. I tried this on Debian squeeze – the trick is that there are *two* places where the variable $display-setup-script is assigned.
    As yet i don’t know if the two assignments are treated differently.


  2. Alek Silver says:

    I have learned that you can simply add a one line to the end of the lightdm.conf file.

    You add this: display-setup-script=xrandr -s 1280×1024

    So this becomes a three step process:

    1. Type in a terminal gksudo gedit /etc/lightdm/lightdm.conf
    2. Add this to the end: display-setup-script=xrandr -s 1280×1024
    3. Save file.

    Of course you can replace 1280×1024 with whatever resolution you want, providing you system will actually run your desired resolution.

  3. Ezio Sella says:

    Hi All,

    I am facing a problem with a VirtualBox resolution,
    i would like to work at 1080x1920_60.00 in portrait mode
    but at the “xrandr –addmode VBOX0 1080x1920_60.00” the
    system return:

    X Error of failed request: BadMatch (invalid parameter attributes)
    Major opcode of failed request: 140 (RANDR)
    Minor opcode of failed request: 18 (RRAddOutputMode)
    Serial number of failed request: 20
    Current serial number in output stream: 21

    Any ideas if is it possible to do this?

    Thanks in advance

Leave a Reply

Your email address will not be published. Required fields are marked *