One computer – two workstations

If you run Linux, need multiple workstations but only have one computer with at least one graphics adapter, you could build a multi headed workstation. Don’t expect high speed graphics, because almost certainly there will be no graphics acceleration in your final “Hydra” system as it is called by some people.

What you need:

  • a graphics adapter with two outputs, able to work in the mode called “extended screen” (I used an Intel onboard video card, G33)
  • two monitors, two mouses and two keyboards, of course
  • recent versions of Xorg and Xephyr (I tried Ubuntu 8.04, including Xorg 7.3)

I used the great tutorial from Josean. In this article, I will present the additional fine tuning I needed to get a system that fulfills my expectations.

Mouse wheel

After successfully completing the tutorial, the mouse wheel will not work in your shiny new environment. The developers of Xephyr decided for some reason to limit the number of buttons to 3. This can be circumvented by patching a single line in the Xephyr source code as recommended in the comments for the second step of the tutorial. To summarize the process:

aptitude install apt-build
echo "deb file:/var/cache/apt-build/repository apt-build main" > \
apt-build source xserver-xephyr

Now you have the Xephyr source code on your hard drive. You can find it in /var/cache/apt-build/build/xorg-server-1.4.1~git20080131 (the last part may differ if a new version was released since I wrote this).

Now, you need to change the line that causes the trouble: It is located in the source tree in hw/kdrive/src/kinput.c. The original line looks like “pi->nButtons = 3;” (without the quotation marks). Replace the number by 5 and save the file. Now you are ready to compile the code (may take a while), build a Debian package and install it to your system. This is all done by one single line:

apt-build install xserver-xephyr

Finally, you need to ensure that your newly built package doesn’t get replaced by the original from the official repository. This is done by setting its dpkg status to “hold”:

echo xserver-xephyr hold|dpkg --set-selections

Some other packages that got built will be reverted to the original while doing “aptitude upgrade” for the next time, but this does no harm as long as xserver-xephyr will still be on “hold”.

Update: This does not suffice, I needed to add the file /etc/apt/preferences with the following contents:

Package: xserver-xephyr
Pin: origin ""
Pin-Priority: 1001

Easy switching between normal and Hydra mode

For me, one additional requirement was to have a simple way of switching between single user and Hydra mode so I can decide whether I want to have two screens for one person or one screen for each person. I have two sets of configuration files (gdm.conf, xorg.conf) – one for each mode. In short:

/etc/X11/xorg.conf-single: X configuration for single user mode
/etc/X11/xorg.conf-dual: X configuration for Hydra mode
/etc/gdm/gdm.conf-single: GDM configuration for single user mode
/etc/gdm/gdm.conf-dual: GDM configuration for Hydra mode

In principle, what you need to do to switch between the modes is copy xorg.conf-single or xorg.conf-dual over xorg.conf (same thing with gdm.conf) and reload the GDM configuration. After the next logout, the mode will be changed.

I could have written a small shell script for this purpose, but I wanted that every user of the machine can change the mode. Therefore, I needed a setuid program (for security reasons, you cannot have a setuid shell script). Here is my C source code: toggle-disp.c.tar.gz

Compile it by issuing “gcc -O2 -Wall -o toggle-disp toggle-disp.c”, move the resulting “toggle-disp” to /usr/local/bin and do “chown root:root” and “chmod +s” on the file so everyone can run it with root privileges.

Now your users can switch the mode by issuing “toggle-disp single” or “toggle-disp dual” and logging out.

Remaining problem: mouse sensitivity

When using Hydra mode, my mouse is too slow. This cannot be fixed by adjusting the mouse speed in the Gnome mouse applet. If someone knows a workaround: just tell me 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *