Wednesday 27 August 2008

How do I set a dual screen output for Linux Ubuntu/Kubuntu?

Linux does have many good things, but sometimes you really need to try hard to get the best of it, or even to do what is taken for granted, say, in Windows. One example is for allowing a laptop to use an external monitor. I have a Dell laptop, model XPS M1210 with nVidia graphics card. The laptop has two partitions, one with Windows Vista, and the other with Linux Ubuntu or Kubuntu, both are basically the same thing with different clothes. I use this laptop to give lectures at Macquarie University and therefore the external monitor is essential. But I haven't yet managed to use the external monitor under Ubuntu easily.

Under Windows Vista, you just need to type Fn+F8. This combination of keys alternates the use of the laptop screen, the external screen, or both. However, in Ubuntu you first need to do a lot of under-the-hood tinkering until you get something that works somewhat.

First, I had to install the nVidia driver. Some time ago I unsuccessfully tried to do it, until I found Envy, an installer written by Alberto Milone that does all the job very easily. Thanks so much Alberto! This was last year, when I was using a former version of Ubuntu (was it Feisty Fawn...?). Recently I tried to use it again to re-install the driver but it didn't work any more... pity. There are other options, or so the Synaptic Package Manager tells me. I tried some of them but I don't remember which ones worked and which ones didn't work.

Anyway, once you get the driver installed you need to edit one of those mysterious files, in particular the file /etc/X11/xorg.conf. Before you even think of editing this file it's best if you make a back up of it, otherwise you might not be able to use your graphic display any more. Since you need the superuser privileges you need to type the following:
sudo cp xorg.conf xorg.conf.bkup
Then, edit the file using your favourite editor. Mine is emacs. Since you need to use superuser privileges to edit this file, you edit it by typing:
gksudo emacs xorg.conf
Then you need to specify that the screen uses Twin View, and some characteristics such as screen resolution. This is what I added to the entry Section "Screen":
#    Option         "RenderAccel" "True"
Option "TwinView"
# Option "TwinViewOrientation" "Clone"
Option "MetaModes" "1280x800,1280x800; 1280x1024,1280x1024; 1024x768,1024x768"
Option "SecondMonitorHorizSync" "50"
Option "SecondMonitorVertRefresh" "60"
# Option "UseDisplayDevice" "DFP, CRT"
# Option "ConnectedMonitor" "CRT"
Noted that some of the text is commented out? This is because I haven't yet managed to work the way I want, but I'm coming to this in a minute. Just to finish, you need to save the file, plug the external monitor, and then restart the window manager by typing Alt-Ctrl-Backspace. You could also restart the system completely but of course that takes longer.

In theory this should make it work, or at least the tutorials listed below say. But I haven't yet managed to have both the laptop screen and the external monitor active. More often than not, the laptop screen appears completely blank and I can only use the external monitor. I tried to add other options following some suggestions from the Internet, but none of them helped, and in some occasions (such as the options "useDisplayDevice" and "ConnectedMonitor" made things worse.

So well, I can use the external monitor after several hours of trying, but it's not yet the way I wanted it to work... I'll keep trying.

Some tutorials that I used:

No comments: