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:

Monday 4 August 2008

Setting the default display manager in Ubuntu/Kubuntu

One of the good things of Ubuntu, and Linux in general, is that there is a wide range of windows managers. You aren't stuck to the look and feel given by a company, but you can choose among several options. Two of the most popular windows managers in the Linux world are GNOME and KDE. The default manager in Ubuntu is GNOME, but if you use Kubuntu, the default is KDE.

Kubuntu and Ubuntu are very much the same thing but the looks are different, using different user interface philosophies. Ubuntu/GNOME is robust and ideal for those who want to use the computer for productivity, whereas Kubuntu/KDE is flexible and customisable and ideal for those who like looking "under the hood", but it's less reliable (sometimes you really need to look under the hood to fix some specific problems).

I generally find the look and feel of GNOME more elegant, and that of KDE more nerdy, but that's just my opinion.

I sometimes like GNOME, other times prefer KDE, and I end up switching from one to the other whenever one of them announces a new improvement, which is quite often.

But surprisingly I found very little information about how to switch from one to the other... finally, after looking here and there, I found out. It's simple, as these things are once you know them. Here's what you need to do:
  • If you are under Ubuntu (GNOME) and want to switch to Kubuntu, simply install kubuntu-desktop by using Synaptics or your favourite package manager
  • If you are under Kubuntu (KDE) and want to switch to Ubuntu... well, simply install ubuntu-desktop by using adept_manager or your favourite package manager
KDM and GNOME have their own display managers, and oddly enough KDM does work fine under GNOME's display manager, and vice-versa. So there's no real need to change display managers unless you want to. To do this, after installing kubuntu_desktop or ubuntu_desktop simply edit the file /etc/X11/default-display-manager so that it has the following contents:
  • /usr/sbin/gdm to set GDM, that is, the Gnome display manager
  • /usr/bin/kdm to set KDM, the KDE display manager
  • /usr/lib/kde4/bin/kdm to set KDM for KDE4, the new version of KDE which is still under experimentation. To use KDE4 you will need to install the package kubuntu-kde4-desktop (you guessed right)
I like the look and feel of GNOME but I want the flexibility of many of the programs associated with KDE (such as digikam for managing photos, or amarok for playing music). The good thing is that these programs also run under GNOME so it is actually possible to get the best of both worlds.