Guerrilla Tactics to Force Screen Mode in Ubuntu

Readers of my previous posts will know about the bad luck I've had when it comes to getting the screen setup on Linux, particularly with Ubuntu Linux. It's a particularly annoying problem when the hardware detection goes wrong and one is presented with a list of unsuitable screen modes. What follows is a way of using XRandR (X Rotate and Resize) to brute force a desired screen mode for X when conventional routes have failed.

Once you've added the new mode and tested that it works, you can add it to your xorg.conf or to the startup script of your login manager. Most of what follows assumes that you are using Ubuntu Linux, but it should work just as well with all but the most unusual distributions.

If you're having a problem whereby your monitor immediately goes blank and reports that the incoming signal is out of range when X starts, it might be worth attempting to the change the screen mode by hitting ctrl+alt+[minus symbol]. Repeatedly pressing this combination might select a screen mode that your monitor can display.

Once you have a usable display, open up a command line and type:


When you invoke XRandR with no parameters, it lists the currently supported screen modes. Typical output might look something like this:

Screen 0: minimum 800 x 600, current 800 x 600 , maximum 800 x 600
default connected 800x600 +0+0 0mm x 0mm
800x600 60.0

If the screen resolution and refresh rate that you need are listed here, it might be a good idea to try changing the screen mode using the standard tools for your desktop environment or the specific tools for your graphics card driver.

If your desired resolution is not displayed, you can add it to the system using XRandR. First generate a modeline for your screen setup using the cvt command. For example, if you need a screen mode of 1280x1024 at 60Hz, type:

cvt 1280 1024 60

The output should look something like this:

# 1280x1024 59.89 Hz (CVT 1.31M4) hsync: 63.67 kHz; pclk: 109.00 MHz
Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync

Add this mode to the system using XRandR

xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync

I got the technical information I needed by copying and pasting everything after the word “Modeline” from the output of cvt. Now type “xrandr” again to make sure that the new mode has been added to the system. You should see it listed along with the other modes. Note that the string “1280x1024_60.00" in that example is simply the name of the mode, the actual numbers in the name are irrelevant. Once the mode has been created, attach it to a display output using the following.

xrandr --addmode default 1280x1024_60.00

On my setup, the display output is called “default”, as revealed by the second line of the output of the xrandr command with no parameters. Now try changing to the new screen mode.

xrandr --output default --mode 1280x1024_60.00

If this works, you're ready to make the change permanent. You can do this by editing the xorg.conf file or adding a command sequence to a startup file.

Basically, you add the modeline to the “Monitor” section of your xorg.conf file and the mode itself to the “Display” subsection within the “Screen” main section, adding to or replacing what's already there.

So, in keeping with the above examples, the Monitor section should look something like this:

Section "Monitor"
    Identifier "default"
    Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync 
    Option "PreferredMode" "1280x1024_60.00"

and the Screen section something like:

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
    Modes “1280x1024_60.00”
        Depth       24

Reboot and see if you have a working display.

Another way of doing this is to add the command sequence that you've already used to your login manager. This is a last resort if other means simply refuse to work, but it works pretty well. In the case of KDM, the KDE4 login manager, you should be able to edit the startup script by typing

sudo kwrite /etc/kde4/kdm/Xsetup

The equivalent GDM (Gnome) file is “/etc/gdm/Init/Default”. Using the setup above as example, simply cut and paste the following lines to this file.

xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync
xrandr --addmode default 1280x1024_60.00
xrandr --output default --mode 1280x1024_60.00

There you have it, a rather guerrilla method of forcing the screen to do what you want.

Load Disqus comments

Community Events

Boston, MA, USA
Park City, UT, USA
New Orleans, LA, USA
Copenhagen, Denmark
Austin, TX, USA