This HOWTO explains how to attach two monitors, two keyboards and two mice to a computer with only one two-head video-card. If you have two video-cards, you should read MultiseatX instead of this HOWTO. The instructions are for Ubuntu 10.04 LTS (lucid).

Display manager with support for XDMCP

A lot can go wrong with this setup and the fancy splash screen during the boot doesn't help. In order to disable it (maybe temporarily) edit /etc/default/grub and change the GRUB_CMDLINE_LINUX_DEFAULT assignment from quiet splash to nomodeset noplymouth. Then run sudo update-grub.

The version of gdm in lucid is severely broken. It is not as configurable as version 2.20 and it doesn't even support some basic X protocols such as XDMCP. I suppose you should be able to use kdm, wdm or xdm instead of gdm, but for my setup I decided to use gdm-2.20. I suppose there are better ways to install the gdm-2.20 but my method also works.

First, download the package from Then go to the text console (Ctrl+Alt+F1), login, purge gdm (this is important), make sure /etc/init/*gdm* doesn't exist and install gdm-2.20:

sudo su
dpkg --force-depends --purge gdm
ls /etc/init/*gdm*
dpkg --install my_download_dir/gdm-2.20_2.20.10-0ubuntu3_amd64.deb
apt-get install -f

The standard configuration of gdm-2.20 assumes that some directories (such as /usr/X11R6) exist. It is possible to correct the configuration of gdm but I preffered to create these missing directories:

mkdir /usr/X11
ln -s ../bin/X11 /usr/X11/bin
ln -s . /usr/X11R6

Now it is time to test what you have done. Reboot the system and test that there is no splash screen and gdm starts. A message about missing theme may appear, don't be alarmed by it.

If you want to start or stop this version of gdm, then don't use start gdm and stop gdm. Use /etc/init.d/gdm start and /etc/init.d/gdm stop instead.

Login in order to install some gdm themes. Use apt-cache search gdm-theme to see the available themes and then install some. Run sudo gdmsetup. Under the Local tab select some theme and uncheck Show Actions menu. Under the Remote tab select Style: Same as Local. Then one important step: execute the following commands:

rm /etc/alternatives/gdm-config-derivative
ln -s /etc/gdm/gdm.conf /etc/alternatives/gdm-config-derivative

This step is required because we will need to edit /etc/gdm/gdm.conf and the themes often disable this configuration file.

Extended desktop through both monitors

The next step is to make your two monitors provide you with one bug desktop extended through both monitors. Create a file /etc/X11/xorg.conf with the following contents. This configuration assumes you are using some free-software driver - the non-free drivers often do not support the last version of the RANDR extension. Look at the lines marked with '### EDIT ###' and change them appropriately. The numbers at the Virtual line depend on the resolutions of your monitors. In my case I have one 1920x1080 monitor attached at the DVI output of the card and another 1280x1024 monitor attached at the VGA output. Then 3200=1920+1280 and 1080=max(1080,1024).

Section "Monitor"
        Identifier      "monitor0"

Section "Monitor"
        Identifier      "monitor1"
        Option          "RightOf" "monitor0"

Section "Device"
        Identifier      "card0"
        Driver          "radeon"                     ### EDIT ###
        Option          "Monitor-DVI-0" "monitor0"   ### EDIT ###
        Option          "Monitor-VGA-0" "monitor1"   ### EDIT ###

Section "Screen"
        Identifier      "screen0"
        Device          "card0"
        Monitor         "monitor0"
        DefaultDepth    24
        SubSection "Display"
                Depth   24
                Virtual 3200 1080                   ### EDIT ###

Section "ServerLayout"
        Identifier      "default"
        Screen          "screen0"

Turn both monitors on and test the configuration (run the following command from the text console):

/etc/init.d/gdm restart

If everything is ok then you should see the gdm login screen on one of the monitors. Login and test that you can move the windows from one of the monitors to another. If you want you can also test that 3D effects work but this is not necessary and depends on the card you have.

Disable the local X server in gdm, enable XDMCP connections

The next step is to make gdm listen for XDMCP connections and make it not run the X server. First, find in /etc/gdm/gdm.conf, in the [servers] section a line starting with 0=.... (without # at the beginning of the line). Put a # in front of it. Then edit /etc/gdm/gdm.conf-custom. Find the [security] section and add a line PamStack=gdm-2.20, then find the [xdmcp] section and add a line Enable=true. XDMCP is not particularly secure protocol so it is a good idea to make gdm refuse connections from other computers. Add a line gdm: 127.* in /etc/hosts.allow and a line gdm: ALL in /etc/hosts.deny.

Time to test. Run the following command in the text console:

/etc/init.d/gdm restart

If you see the gdm login screen then there is something wrong with the gdm configuration. Check it again.

If there is no login screen and X is not running, then run the following command:

X -query

Now you should see the login screen of gdm. Kill it (for example, go back to the text console and press Ctrl-C).

New user "monitor"

We are going to use a special user called "monitor" in order to start the graphical environment. It is not a system user - it has normal home directory (this helps debugging) but we will create it with a non-standard number. This number ensures the user "monitor" will be hidden in the login screen of gdm. Make sure you give a strong password of this user.

addgroup --gid 983 monitor
adduser --uid 983 --gid 983 monitor

In order to be able to control the keyboards and the mice of the computer, the user "monitor" has to have full access to the files in /dev/input. In order to achieve this, create a file /etc/udev/rules.d/my.rules with the following contents:

SUBSYSTEM=="input", OWNER="monitor", GROUP="monitor"

I don't know how to test this without reboot, so reboot the machine and make sure the files in /dev/input are owned by "monitor".

Two desktops

Now the final stage. We need to install some packages:

apt-get install x11-utils xserver-xephyr

Now we are going to make the user "monitor" start the X server and two instances of Xephyr. Xephyr is a X server that is able to output to a window on a pre-existing X display. We will run two instances of Xephyr - two windows, one for the first monitor and another for the second one. We will also configure these two instances of Xephyr to take control of the keyboard and mouse. Unfortunately Xephyr doesn't have an option -display which we could use to tell it the exact position and size of the window. Fortunately it has an option -parent that tells it to display in an existing window. So we are going to do this:

  1. Run two windows with the proper size and position. It doesn't matter what program is used for the windows, but are going to use xmessage.

  2. Use xwininfo in order to get the window ID.

  3. Run Xephyr with option -parent

But as we have two windows of xmessage, in order to be able to differentiate between both, we need to change the name of xmessage. Use the following commands to create aliases xmessage0 and xmessage1:

ln -s xmessage /usr/bin/xmessage0
ln -s xmessage /usr/bin/xmessage1

Login with the user "monitor" (on the text console; you don't have a graphical environment yet, do you?). Create a file ~/.xsession with the following contents:

runscreen () {
    # $1 = number
    # $2 = geometry
    local xpid winid k
    while :; do
        xmessage$1 -geometry $2 "Window $1" &
        while \
            winid=`xwininfo -name xmessage$1|grep 'Window id'|cut -d' ' -f4` \
            && [ $k -gt 0 -a ! "$winid" ]
            sleep 1
            k=$(($k - 1))
        if [ "$winid" ]; then
            Xephyr :1$1 -parent "$winid" -dpms -keybd "evdev,,device=$3,$xkb" -mouse "evdev,,device=$4" -query 
        kill $xpid
        sleep 3
        kill -9 $xpid

# For some reason I was unable to set the following in xorg.conf
# We need to turn off power management of the main X server because it doesn't
# see either of the keyboards and the mice so it will enter power-saving mode
# after 10 minutes
xset s off
xset dpms 0 0 0
xset -dpms


# PS/2 keyboard and mouse
kbd1=`ls /dev/input/by-path/platform-*-event-kbd`
mouse1=`ls /dev/input/by-path/platform-*-event-mouse`

# USB keyboard and mouse
kbd2=`ls /dev/input/by-path/pci-*-event-kbd`
mouse2=`ls /dev/input/by-path/pci-*-event-mouse`

runscreen 1 1280x1024+1920+0 "$kbd2" "$mouse2" &
runscreen 0 1920x1080+0+0 "$kbd1" "$mouse1"

Notice - there is ampersand for the first runscreen command and no ampersand for the second. Change the screen sizes appropriately and optionally edit the xkb= line. If you want, you can use static assignments for kbd1, mouse1, kbd2 and mouse2 but I've read that sometimes the file names change. In order to be safe, I have used PS/2 keyboard and mouse for the first monitor and USB keyboard and mouse for the second monitor. Then the commands ls ... will discover the correct file names.

Time to test. Run startx as user "monitor" and enjoy two login screens on your two monitors, each controlled by its own keyboard and mouse.

Automatic start at boot

The last step is to make all this start automatically at boot. Add at the end of ~monitor/.profile the following lines:

if [ "`tty`" = /dev/tty6 ]; then
    exec startx

Kill the graphical environment (killall xinit), go to the sixth text console(Ctrl+Alt+F6), login as monitor and the graphical environment should start.

If everything is ok, edit (as root) /etc/init/tty6.conf and the replace the exec /sbin/getty ... line with the following one:

exec /bin/login -f monitor tty6 </dev/tty6 >/dev/tty6 2>&1

If you want you can reconfigure pulseaudio as described at MultiseatX. It is time to make the final test - reboot the machine and enjoy your two separate desktops.

Multiseat assistant for Ubuntu 11.04 and Ubuntu 12.04

There is an assistant to configure a multiseat system in Ubuntu 11.04 and Ubuntu 12.04.

You can download from:

tags: multiseat, one card, two head, lucid, xephyr

CategoryXwindowSystem CategoryInstallation

MultiseatOneCard (last edited 2012-05-15 20:29:02 by selairi)