# Multiseat Configuration/Xnest

This article describes a way to make a Multiterminal with Xnest. For other ways, see multiterminal.
There are modifications in Xnest that make possible to use it in order to implement a multiterminal system. The system is configured to run one X server controlling all video cards, and one Xnest for each screen, running above the main X server.
While normal Xnest receives events from its parent X server, multiXnest (modified Xnest) reads the input devices events directly from kernel event interface, bypassing the X.

## Operating System required

Debian Sarge (but it's very easy to adapt it to other Linux distributions).

## Introduction

Xnest is an X server that runs inside another X server. Xnest is both an X client and an X server, simultaneously. Xnest is a client of the real X server, but also a server to its own clients. Xnest is normally used to allow working on two or more desktops at the same time, however, we've made modifications in its code to make possible to use Xnest to implement a multiterminal system.
The system works in the following way. Only one "real" X server is run, configured to use several screens, each of which will be associated to one video card. After the X start-up, one Xnest is run inside each screen. Each user will use one Xnest, in a transparent way.
The original Xnest gets the input devices events from its parent X server. However, to allow Xnest to be used in the multiterminal, we had to modify its source code to make it read the events directly from kernel event interface, bypassing the X.
The great advantage of this approach is the possibility to make a multiterminal with any combination of video cards, as long as they are supported by the X.

## Evdev and Udev

Make sure your kernel is compiled with evdev support.
Also install udev, which provides a dynamic /dev directory, updated according to the connected devices:
Udev requires a kernel 2.6.12 or later.

## Input devices

Now, you need to check if your input devices (mouses and keyboards) have been correctly detected by the kernel. In order to do this, analyze the file /proc/bus/input/devices, which show details about the input devices detected by the kernel.
An example of this file is shown below. Only two fields are of interest: the name of each device, shown in the lines starting with “N: Name=”, and the name of the file related to each device, shown in the lines starting with “H: Handlers”.
Notice that the file seem to indicate the presence of 3 keyboards, although the system in question actually has only two. This happens because many USB keyboards have special keys (to control multimedia or access the internet, for instance), which are detected by the kernel as a secoundary keyboard, whose physical address finishes with “input1”. You need to configure only the primary keyboards, whose physical address finishes with “input0”.
The example given show the precense of 2 "primary" keyboards, related to the files /dev/input/event0 and /dev/input/event2, respectively, and 2 mouses, related to the files /dev/input/event1 and /dev/input/event4, respectively.

## XOrg installation

We'll describe the necessary steps to configure a multiterminal using Xorg, but it's possible to use XFree86, with few changes. To install XOrg, on Debian Sarge, do the following:
1. Make a backup and delete the file /etc/init.d/xfree-common. 2. Add the following lines to the file /etc/apt/sources.list:
3. Install the xserver-xorg package:

## Modified Xnest (multiXnest) download

1. Download the multiXnest binary (version 0.1.3) here. The binary should be put in the directory /usr/local/bin. You can download the patch to Xnest (from Xorg 6.8.2) here. 2. Download the wrapper script necessary to run Xnest: multiXnest.sh. The script must be copied to /usr/sbin.

## X(XOrg) configuration

To configure a multiterminal with N terminals, edit the file /etc/X11/xorg.conf, and do the following:
1. Define a layout with N screen's.
2. Define one Device Section for each video card:
3. Define the Monitor Sections.
4. Define the Screen Sections
5. Xorg.conf should have only one keyboard section, like this:
The mouse section can be deleted, which is recommended, but you must add the AllowMouseOpenFail option to the ServerFlags Section, as shown below, otherwise the X server will fail to start.
6. Make sure the ServerFlags section has the following options:

## XKB configuration

Now it's necessary to create an XKB configuration file for each multiXnest. The XKB configuration for the first multiXnest should be placed in the file /usr/X11R6/lib/X11/xkb/X1-config.keyboard, for the second multiXnest in /usr/X11R6/lib/X11/xkb/X2-config.keyboard, and so on. You can see an example of an XKB configuration file below.

## GDM configuration

The last step is to configure the login manager to start the main X server and also to run the wrapper scripts that will open Xnest. We'll explain how to do his on GDM, but other managers, like XDM and KDM, can be configured in a similar way.
Edit the file /etc/X11/gdm.conf in the servers section, adding the following: