Thursday, February 23, 2006

Setting up Multiple X Sessions on a Single Monitor

If you need to run multiple X servers concurrently and let us switch back and forth between them as required. So, Control-Alt-F7 is 1st X server and Control-Alt-F8 is 2nd so on.
First we have to test our second session.

Testing the Second Session

The first step is to test the second session manually. Simply log to a console window (Control-Alt-F1 for example) and type the following:

startx -- :1 vt8

This will start an X server on virtual terminal 8 and the DISPLAY environment variable will be :1.0 instead of :0.0.

The :1 is the display name and vt8 is the virtual terminal number. Since vt7 is the default terminal for X, and I running consoles on vt1-vt6, I chose vt8 for the second X session. Be sure that it isn't already being used for a console. Console VTs are started by /etc/inittab.

Making the Change Automatic

Typically, X is started when init changes to runlevel 5. If you look at /etc/inittab, you will see a record that looks like:

x:5:once:/etc/X11/prefdm -nodaemon

This in turn will run the appropriate display manager. By default, this is gdm or kdm and the choice is dependent on the value of the DESKTOP variable defined in /etc/sysconfig/desktop. Even though desktop is "GNOME", you need to use the xdm display manager since GNOME doesn't support multiple displays. You can override this default by having the following two records in /etc/sysconfig/desktop:

DESKTOP="GNOME"
DISPLAYMANAGER="XDM"

Now, when you switch to runlevel 5 (which is the default at boot time), you will be using the XDM window manager instead of kdm or gdm. The next step is configure xdm to start the second session. This is done by simply adding another record to the /etc/X11/xdm/Xservers file:

:0 local /usr/X11R6/bin/X :0 vt7
:1 local /usr/X11R6/bin/X :1 vt8


Verifying Your Changes

You don't need to reboot for this to take effect. Simply log out of your X session, switch to a lower run-level, and then switch back to run-level 5:

* init 3
* init 5


Then you will see two X sessions when you press
Control-Alt-F7 is 1st X server and Control-Alt-F8 is 2nd
Frist we have to test our second session.

No comments: