Flexible Single/Dual monitor setup in Ubuntu

So I am going to describe how I got my dual monitor setup working in Ubuntu Gutsy. Before reading more and/or trying anything that is described here… first the following:

“I wrote this article solely as a future reference for myself. Doing it yourself can cause severe hard- and software damage. I can and will take no responsibility whatsoever for any damage or any other outcome related with what I described here!”

Then let me tell you some details about my setup and what I want to achieve. I am working on an IBM Thinkpad T42 laptop with a 1400x1050 LCD screen working with an ATI Technologies Inc RV350 [Mobility Radeon 9600 M10] videocard. On the left-hand side of the laptop there is a Novita 1024x768 VGA screen that runs with a refresh rate of about 75Hz.

In short we have:

  • ATI Technologies Inc RV350 [Mobility Radeon 9600 M10]
  • LCD 1400x1050
  • VGA 1024x768

So now we know what we are working with. This description is based on these hardware components. Furthermore it is nice to also present you the software I use:

  • Ubuntu 7.10 - the Gutsy Gibbon - released in October 2007
  • With kernel: Linux version 2.6.22-14-generic Check via: cat /proc/version
  • RandR version 1.2 Check via: xrandr -v

Now I think we are ready to rock and role and so we will after mentioning where I got my information from. First of all from this brilliant website and second of all from “man xrandr” and thirdly from my own logic reasoning! Now lets take it step by step.

Note that the way that is presented here does not infect the way your computer/laptop works when the second monitor is not attached and switched on. Thus this setting is ideal for people who only need the second monitor support at some places.

Step 1

We start with backing up our current, working xorg.conf file and then we replace it with a fresh, working xorg.conf file. For this we do the following:

sudo cp /etx/X11/xorg.conf /etx/X11/xorg.conf.BackupBeforeDualMonitorSetup
sudo dpkg-reconfigure -phigh xserver-xorg

This results in a new xorg.cong that needs to be edited slightly. In the end it should look similar to the one below. You can also download my version –REMOVED–.:

Section "Device"
    Identifier  "ATI Technologies Inc RV350 [Mobility Radeon 9600 M10]"
    Driver      "ati"
    BusID       "PCI:1:0:0"
    Option          "monitor-TV"   "TV" _

Section "Monitor"
    Identifier  "Generic Monitor"
    Option      "DPMS"

Section "Monitor"
    Identifier      "TV"
    Option          "Ignore" "True"
EndSection  _
Section "Screen"
    Identifier  "Default Screen"
    Device      "ATI Technologies Inc RV350 [Mobility Radeon 9600 M10]"
    Monitor     "Generic Monitor"
    DefaultDepth    24
    SubSection "Display"
        Modes       "1400x1050"
        Virtual     2424 1050

There are a few things to notice in this config file.. First the parts that define of there is the possibility for a television. Of course, this depends on you setup how to deal with it. Secondly there are the resolutions. Under “Modes” we set the resolution of the standard LCD screen (from  the laptop), which is in my case 1400x1050. Under “Virtual” we set the total requested resolution which is in this case 1400+1024=2424 and 1050. So we add both screen width (because our screens are next to each other) and we take the biggest height.

Step 2

Now we will take a look on what we have and should use. We reboot our computer with the second monitor attached to the computer and turned on. Thus there are now two monitors connected with the computer and both are turned on. For this we use the command “xrandr -q” which will then generate the following output:

[email protected]:~$ xrandr -q
Screen 0: minimum 320 x 200, current 1400 x 1050, maximum 2424 x 1050
VGA-0 connected (normal left inverted right)
   1024x768       85.0 +   84.9     75.1
   1280x1024      59.9
   800x600        84.9     75.0
   640x480        84.6     75.0     60.0
   720x400        70.1
DVI-0 disconnected (normal left inverted right)
LVDS connected 1400x1050+0+0 (normal left inverted right) 0mm x 0mm
   1400x1050      60.2*+
   1280x800       60.0
   1280x768       60.0
   1024x768       60.0
   800x600        60.3
   640x480        59.9
S-video disconnected (normal left inverted right)

We will need some info from this later on so you might want to save it in a file or use another terminal screen for the parts that are coming up.

Step 3

No we will cover the actual script/command to switch between single and dual monitor setup.

To switch from a single screen setup to the dual screen setup we can use the following cammand/script:

xrandr --output LVDS --mode 1400x1050 --pos 1024x0 --output VGA-0 --mode 1024x768 --pos 0x0

So what does it do. First we noticed before (in step 2) that we have 2 monitors. We have the LVDS and the VGA-0. Please note that these names can differ depending on your hardware. The LVDS screen (= my laptop LCD screen) works with a resolution of 1400x1050. The VGA-0 screen (= the VGA monitor) works on a resolution of 1024x768. My VGA-0 monitor is placed on the left of my laptop. Thus the laptop screen will start at resolution 1024x0 (it is the offset).

Step 4

If we want to detach the VGA-0 monitor from the system and continue working with the laptop we can use the following –REMOVED–:

xrandr --output VGA-0 --off
xrandr --output LVDS --mode 1400x1050 --pos 0x0

This code will first switch off the VGA-0 monitor and then change the output position of the LVDS monitor.

Problems and limitations

This way of working still has some problems and limitations. Let me present them shortly:

  • The dual monitor setup is unstable. This means that my desktop has been freezing many times when using the dual monitor setup. I have not yet been able to pin down the reason for this. These random freezes will make any keyboard and mouse input impossible and will result in a system reboot!
  • The desktop and background is not working. This means that the ~\Desktop folder is not shown on the desktop, The desktop background picture/colour is not shown (it is just a white square). This does not effect my work with the computer, but it is expected to happen with you as well.
  • If you use the scripts that can be downloaded above then you must run them by either making them executable (chmod +x scriptname). I also suggest to delete the “.txt” part of the file names (these are added for security reasons).

Final note

Good luck with trying this yourself. Do not forget to also take a look at the two references I gave above. If you succeed with your setup please let me know. If you succeed in overcoming any of the problems noted above then I am even more curious and I urge you to tell me how you did it!


Anonymous (not verified)

. May 31st, 2008

Hello Patrick,

I used one of these solutions: http://ubuntuforums.org/showthread.php?t=221174 and it works quite good. Everything works fine except I have some trouble with running compiz effects. I used TwinView so in won’t do for you as it’s for nVidia cards only. I hope any other way will do.

I’ve fount your page becouse now I’m loogikng how to load different xorg.conf files depends on what (and how many) monitors are connected to the system. If you know (or anyone else reading this) how to do it - don’t hesitate to mail me saafi~at~wp.pl.



Anonymous (not verified)

. August 26th, 2008

You really sorted me out.  Putting me on the xrandr route, I have managed to get my Compaq nx8220 working in lovely dual screen mode!

Really need to test it in all situations now!

Major annoyance so far - desktop wallpapers (I’m going to have to get gimping) and firefox isn’t aware of the second screen, so all the popups appear on my primary.  To be honest, these are things I can live with!


Anonymous (not verified)

. January 2nd, 2009

Hi Patrick, I found a simple way to switch between single and dual monitors, which I described here: http://ubuntuforums.org/showthread.php?p=6480694 Sam


. January 17th, 2009

 Thank you.

It look spromissing and I will check it when I need it again (i have no 2 monitors at this moment)