Simple dual monitor setup with XrandR in Ubuntu (Linux)

Posted on: Jun-23-2008 07:03:16 PM by Stevan Ljuljdurovic

This article will be a quick tutorial on how to set up a dual monitor display system on linux with the XrandR program. I use the KDE desktop and there is a tool called krandrtray that tries to set up the two monitors for you, but quite often it fails. So here is how you can do it yourself manually:

First you need to figure out the resolution of both your monitors. In my case I have a 22" monitor with a 1680x1050 resolution and my laptop monitor with a 1200x800 resolution.

Now that we have both of our monitors we need to figure out how we our displays set up. You can have it set up so your external monitor (in my case the 22" monitor) is left-of | right-of | above | below | same-as your default monitor. Note: same-as just clones your default monitor

Now its just time for some simple math. We are going to need to set a virtual resolution, so depending on how you want your monitors set up, you need to set your virtual resolution accordingly. For me, I have my 22" above my laptop monitor so I use the above option. I need total width of 1680px and a total height of 1050+800=1850px. So my virtual resolution would be 1680 1850. If I were to put my 22" monitor to the left of my laptop monitor my resolution would be a width of 1680+1280=2960 and a height of 1050, making a total virtual resolution of 2960 1050. Note: Virtual screen is limited to 2048x2048 for intel

Now that we have our resolution we need to add just one line to our xorg file. Before doing this please please make a backup, I take no responsibility if anything breaks.

To backup: sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
Add the virtual line to your xorg under the screen section, here is what mine looks like:

Section "Screen"
        Identifier      "Default Screen"
        Device          "Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
        Monitor         "Generic Monitor"
        DefaultDepth    24
        SubSection "Display"
                Modes           "1680x1050" "1280x800"
                Virtual          1680 1850
        EndSubSection
EndSection

Now plug in your external monitor and restart X (alt+ctrl+backspace). We are ready to get you dual monitor layout working. For me I open up a terminal and type:

xrandr --output LVDS --mode 1280x800 --output VGA --mode 1680x1050 --above LVDS

Note: I actually just have a script that runs that command, all you have to do is make a simple bash script, and make it executable. Here is how:

Create a file on your desktop called dualscreen, or whatever you want.
Now simply add:

 
#!/bin/bash

xrandr --output LVDS --mode 1280x800 --output VGA --mode 1680x1050 --above LVDS


Now make the file executable: sudo chmod +x dualscreen . There you have it, click the script everytime you plug in your external monitor and you should have dualscreen working!

Now you need to modify that line based on your settings, here is the default line.

xrandr --output <output> --rate <rate> --mode <mode> --left-of|--right-of|--above|--below|--same-as <output>

Here is a list of the output names depending on what video card you are using and what type of monitor you have:



Intel

Output names:
* LVDS: internal laptop panel
* TMDS-1: external DVI port
* VGA: external VGA port
* TV: external TV output

ATI

Output names:
* LVDS: internal laptop panel
* DVI-0: first external DVI port
* DVI-1: second external DVI port (if present)
* VGA-0: first external VGA port
* VGA-1: second external VGA port (if present)
* S-video

Nvidia

Output names:
* LVDS: internal laptop panel
* DVI0: first external DVI port
* DVI1: second external DVI port (if present)

For a more in depth explanation with more examples please see this tutorial

Your Ad Here

Related Information:


Comments

Bryan St. Amour
Posted on: 2008-06-24 21:21:00

Wow Steve, I must say that that was a very informative article. That command line program you used - xrandr - is that only for KDE? Or is it a utility that us GNOME users can use too? On the topic of Unixy stuff, I recently finished a new post that you and your readers might enjoy: http://bryanstamour.com/?p=42

Bailey
Posted on: 2008-06-30 17:49:44

Good article. I\'m caught in bleeding edge hell with my nvidia card and running ubuntu intrepid ibex alpha1. Had to go back to using the nv driver instead of nvidia, but thanks to your tips, I have the dual display working.....which I keep forgetting to save.

Old Friend
Posted on: 2009-07-20 09:26:44

Excellent, I was looking for this. I have recently moved to Ubuntu from Windows and there is a lot to learn.

Pablo Olmos de Aguilera Corradini
Posted on: 2009-08-13 19:14:29

Thanks! A perfect article. It worked flawlessly on an Inspiron 1501 running Xubuntu 9.04 and the open source "ati" drivers :).

Tim
Posted on: 2009-09-27 01:11:28

THanks for this. I like the default setting of "above" which gets around a compiz restriction for my setup, since the total desktop dimensions stay within the driver's bounds for composition support. Putting one screen to the left of the other makes it too wide for the intel driver. Now I just have to work out how to tell KDE which is the main monitor

FredJ
Posted on: 2010-01-20 09:13:24

Thank You so much. Saved a couple hours of my life. Cheers!


Post a comment!

Full Name:
Email Address:

Website:
2+3=
Leave a Message:
Design and Content © 2008 Stevan Ljuljdurovic

Admin Login

Whats new?

Wonderful news! I have made some new websites.

HpArea which is a website that is based on user contributed health related information.

Anonymous email sender which is used to send emails from anyone to anyone!

Login!

Name:
Password:
Create Account!
Go ahead, Create an account! Even though you can't do anything with it now, there might be a use for it in the future!

Quote

Everyone laughs and cries in the same language.
Unknown
Your Ad Here

Friends

yes