Sunday, September 12, 2010

How to Add and Set Custom Display Resolutions using xrandr Command on ubuntu 10.04 (lucid lynx) Linux

You can change your monitor's display resolution from system->preferences->monitors,but in some cases Linux fails to detect the proper resolutions for your monitor,in such situations we can add and set custom resolutions with a little effort by using xrandr command.

As it is said in the man pages:

     “ Xrandr  is  used  to set the size, orientation and/or reflection of the
        outputs for a screen. It can also set the screen size.

        If invoked without any option, it will dump the state of  the  outputs,
        showing  the existing modes for each of them, with a '+' after the pre‐
        ferred mode and a '*' after the current mode.......”

Here is the output of my terminal window when I issued the xrandr with -q option:

sunny@usmanriaz-desktop:~$ xrandr -q


Screen 0: minimum 320 x 200, current 1280 x 768, maximum 4096 x 4096
VGA connected 1280x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1360x768       59.8 
   1152x864       60.0 
   1024x768       60.0 
   800x600        60.3 
   640x480        59.9 
   1280x768_60.00   59.5*

To add a new mode xrandr provides us '--newmode' and '--addmode' options which are used to create and associate modes for the perticular display respectively.

--newmode option also requires a mode line .For example if you want to add a resolution 1280x800
the mode line will be:

"1280x800_60.00"   83.50  1280 1352 1480 1680  800 803 809 831 -hsync +vsync

I have calculated the above mode line using  cvt  (VESA Coordinated Video Timing)  utility by issuing the following command:
sunny@usmanriaz-desktop:~$ cvt 1280 800
(note: replace 1280 800 with your required resolution)

# 1280x800 59.81 Hz (CVT 1.02MA) hsync: 49.70 kHz; pclk: 83.50 MHz
Modeline "1280x800_60.00"   83.50  1280 1352 1480 1680  800 803 809 831 -hsync +vsync

Now we have the mode line next step is to use this mode line with --newmode option as follows:

sunny@usmanriaz-desktop:~$ xrandr --newmode "1280x800_60.00"   83.50  1280 1352 1480 1680  800 803 809 831 -hsync +vsync

After the above command your mode will be listed in the xrandr -q output take a look at this output:

# xrandr -q

   1360x768       59.8 
   1152x864       60.0 
   1024x768       60.0 
   800x600        60.3 
   640x480        59.9 
   1280x768_60.00   59.5*
   1280x800_60.00 (0x123)   83.0MHz
        h: width  1280 start 1352 end 1480 total 1680 skew    0 clock   49.4KHz
        v: height  800 start  803 end  809 total  831           clock   59.5Hz

Now I am going to associate this mode with VGA(current connected display name) it can be different on your machine.

sunny@usmanriaz-desktop:~$ xrandr --addmode VGA 1280x800_60.00

To set this custom mode on your display just type the following command:

# xrandr --output VGA --mode 1280x800_60.00


The Last Thing :

Though by following above steps we can change the resolution but these changes will  not be permanent , your old resolution will be restored when you reboot your system.

To make these changes permanent type in the following command in your terminal :
# sudo vim  /etc/gdm/Init/Default

and put the following commands before the Line Number 11 as shown in figure:

# xrandr --newmode "1280x800_60.00"   83.50  1280 1352 1480 1680  800 803 809 831 -hsync +vsync

#xrandr --addmode VGA 1280x800_60.00

# xrandr --output VGA --mode 1280x800_60.00

Please write me your comments and correct me on my mistakes ..!


  1. When I try to use xrandr --addmode HDMI-0 1176x664_60.00 i get an error!

    This is the output error:
    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: 29
    Current serial number in output stream: 30

    What should I do to fix it?

  2. You should put a # before xrandr to force add it.

  3. And if you have mint 14 it is sudo cat /usr/share/alsa/init/default

  4. We create websites for customers large and small with innovative designs, visual impact and bespoke levels of functionality.Webbitez are a friendly UK based company with the in-house skills mix to create websites and associated marketing materials. Our core skills include marketing experience, design, professional photography plus coding expertise and programming capabilities. Web Design Belfast Northern Ireland | SEO Belfast Northern Ireland | Logo Design Northern Ireland UK | Hosting Services Northern Ireland UK | Ecommerce Sites Belfast Northern Ireland |

  5. All service providers problems solved with fast, accurate, with a simple phone contact number for all your favourite Websites. Having difficulties with a social network site? Or need help or advice with any social networking issues and cant find a providers telephone contact number? Direct Contact Numbers will cut out all the relentless searching for telephone numbers online. Facebook Helpline Contact Number | Amazon Helpline Contact Number | Gmail Helpline Contact Number | Google Helpline Contact Number | Twitter Helpline Contact Number |

  6. On firing xrandr --output ... , my screen went black and I had to hard boot ...


Follow me

Join me on the New Digg Follow ur_sunny on Twitter

Share it