Dual Monitor Dual X Server One Input
1. Introduction
This HOWTO describes setting up a single computer which has two monitors on two separate video cards but only one keyboard and mouse such that there is a separate X server running for each display with a separate login session for each.
1.1 System
- Two video cards
- Two monitors
- One keyboard, One mouse
- Running Debian Lenny (5.0)
- Two user accounts, one for the primary display and one for the secondary
- A shared group for the two accounts (it doesn't need to either user's primary group)
- gdm (GNOME Display Manager) as the display manager
- sudo installed (gdm pulls it in debian)
- X.Org
- void input driver for X.Org (package xserver-xorg-input-void)
- Package x2x
2. Overview
- Create configuration for the X servers (xorg.conf and xorg.conf.1)
- Modify gdm (GNOME Display Manager) configuration to start both servers
- Configure login to primary display so that we obtain authorization for the secondary display
- Create script to copy secondary display authorization to our primary display
- Put an entry in /etc/sudoers so that we can execute the command as root (required)
- Add a line to $HOME/.xsessionrc (for users who will use both displays) to execute that command on login
- Share the mouse with the secondary display until login (because login knocks off our access)
- On login to the secondary display obtain authorization to the primary display
- Share the mouse and keyboard from the primary display
3. The Configuration
3.1. Create configuration for the X servers
3.1.1. For Primary Display
Example /etc/X11/xorg.conf
Section "InputDevice" Identifier "Generic Keyboard" Driver "kbd" Option "XkbRules" "xorg" Option "XkbModel" "pc104" Option "XkbLayout" "us" EndSection Section "InputDevice" Identifier "Configured Mouse" Driver "mouse" EndSection Section "Device" Identifier "Configured Video Device" BusID "PCI:01:00:00" Driver "radeon" Option "Int10" "false" EndSection Section "Monitor" Identifier "Configured Monitor" Option "DPMS" Option "PreferredMode" "1600x1200" EndSection Section "Screen" Identifier "Default Screen" Device "Configured Video Device" Monitor "Configured Monitor" Option "NoInt10" "true" EndSection Section "ServerLayout" Identifier "Primary Display" Screen "Default Screen" InputDevice "Generic Keyboard" "CoreKeyboard" InputDevice "Configured Mouse" "CorePointer" Option "IsolateDevice" "1:0:0" EndSection
The most important settings above are:
BusID "PCI:01:00:00" Option "IsolateDevice" "1:0:0"
If you're having trouble with displays hanging during initialization the following settings (from above) are also important:
Option "Int10" "false" Option "NoInt10" "true"
The BusID and ?IsolateDevice settings take the PCI id information in decimal. lspci lists the devices with PCI id information in hexadecimal (base 16), so you will have to convert the numbers to decimal to use the in xorg.conf.
Note the BusID for the configuration for the secondary display (below)
BusID "PCI:2:14:0"
It is associated with the lspci line
02:0e.0 VGA compatible controller: ATI Technologies Inc 3D Rage II+ 215GTB [Mach64 GTB] (rev 9a)
Sample lspci output:
00:00.0 Host bridge: Intel Corporation 82845 845 [Brookdale] Chipset Host Bridge (rev 04) 00:01.0 PCI bridge: Intel Corporation 82845 845 [Brookdale] Chipset AGP Bridge (rev 04) 00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 05) 00:1f.0 ISA bridge: Intel Corporation 82801BA ISA Bridge (LPC) (rev 05) 00:1f.1 IDE interface: Intel Corporation 82801BA IDE U100 Controller (rev 05) 00:1f.2 USB Controller: Intel Corporation 82801BA/BAM USB Controller #1 (rev 05) 00:1f.3 SMBus: Intel Corporation 82801BA/BAM SMBus Controller (rev 05) 00:1f.4 USB Controller: Intel Corporation 82801BA/BAM USB Controller #1 (rev 05) 01:00.0 VGA compatible controller: ATI Technologies Inc Radeon RV200 QW [Radeon 7500] 02:09.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 (rev 04) 02:0a.0 PCI bridge: Digital Equipment Corporation DECchip 21154 (rev 05) 02:0b.0 Multimedia audio controller: Creative Labs SB Audigy (rev 04) 02:0b.2 FireWire (IEEE 1394): Creative Labs SB Audigy FireWire Port (rev 04) 02:0c.0 Ethernet controller: 3Com Corporation 3c905 100BaseTX [Boomerang] 02:0d.0 Serial controller: 3Com Corp, Modem Division 56K FaxModem Model 5610 (rev 01) 02:0e.0 VGA compatible controller: ATI Technologies Inc 3D Rage II+ 215GTB [Mach64 GTB] (rev 9a) 03:00.0 PCI bridge: Digital Equipment Corporation DECchip 21154 (rev 05)
3.1.2. For Secondary Display
Example /etc/X11/xorg.conf.1
Section "InputDevice" Identifier "Generic Keyboard" Driver "void" Option "CoreKeyboard" EndSection Section "InputDevice" Identifier "Configured Mouse" Driver "void" Option "CorePointer" EndSection Section "Device" Identifier "Configured Video Device" BusID "PCI:2:14:0" Driver "mach64" EndSection Section "Monitor" Identifier "Configured Monitor" EndSection Section "Screen" Identifier "Secondary Screen" Device "Configured Video Device" Monitor "Configured Monitor" DefaultDepth 16 EndSection Section "ServerLayout" Identifier "Secondary Display" Screen "Secondary Screen" InputDevice "Generic Keyboard" "CoreKeyboard" InputDevice "Configured Mouse" "CorePointer" EndSection
Notice the following setting:
Driver "void"
This requires the package xserver-xorg-input-void be installed (on Debian; other distributions will make the void driver available in other ways). Setting the mouse and keyboard driver to void and using
InputDevice "Generic Keyboard" "CoreKeyboard" InputDevice "Configured Mouse" "CorePointer"
means that the server associated with this configuration has not access to input devices on the server (until we use x2x) and must therefore be controlled through software.
3.2. Configure GDM to start both servers
Here is an example /etc/gdm/gdm.conf
[daemon] [security] [xdmcp] [gui] [greeter] [chooser] [debug] [servers] 0=Primary 1=Secondary [server-Primary] name=Primary Display command=/usr/X11R6/bin/X -audit 0 -isolateDevice PCI:1:0:0 vt7 flexible=true [server-Secondary] name=Secondary Display command=/usr/X11R6/bin/X -audit 0 -config /etc/X11/xorg.conf.1 -isolateDevice PCI:2:14:0 -sharevts flexible=true
The import parts are the server* sections. Note the -isolateDevice parameter (which is the same as the BusID) and for the secondary display -config /etc/X11/xorg.conf.1
3.3. On primary login, obtain authorization to use secondary display
3.3.1. Script to copy secondary display authorization
#!/bin/sh xauth -f "$1" merge /var/lib/gdm/:1.Xauth chown user:group "$1" /bin/chmod g+r "$1"
If you call this script merge-gdm-auth, it would used as:
merge-gdm-auth "$XAUTHORITY"
if you want to get the authorization for the secondary display into the user who just logged in.
* user is the user name of the primary user * group is the shared group of the primary user and secondary user
3.3.2. Allow primary user to run the script as root
Modify /etc/sudoers with a line such as:
daniel ALL=(root) NOPASSWD: /usr/local/bin/merge-gdm-auth
3.3.3. Execute the command on login
Add a line such as the following to $HOME/.xsessionrc (for users who will use both displays)
sudo /usr/local/bin/merge-gdm-auth "$XAUTHORITY"
3.4. Share the mouse and keyboard with secondary display
3.4.1. Before login on secondary display
Make sure the command x2x is present on your system (package x2x on Debian) and add the following line to $HOME/.xsessionrc:
x2x -to :1 -east &
That gets us a mouse and keyboard we can use to move over to the secondary monitor (on the right)
3.4.2. After login on secondary display
We first need to make sure that the secondary user is able to obtain the authorization to use the primary display (for x2x)
3.4.2.1a. Method One
- Make sure the primary and secondary user share the same primary group
- Make the primary user's home directory group-readable and group-executable
- On login as the primary user, create a symlink to the $XAUTHORITY file (authorization for the primary display; will not be the default $HOME/.Xauthority if we use this method because GNOME doesn't like those perms)
- On login as the secondary merge in the primary user's authorization (via the link)
- Launch x2x to use the mouse and keyboard from the primary user
3.4.2.1a.4. Merge in primary user's authorization
In secondary user's $HOME/.xsessionrc
xauth -f "$XAUTHORITY" merge /home/daniel/.Xauthority-link
3.4.2.1a.5. Launch x2x
In secondary user's $HOME/.xsessionrc
x2x -from :0 -east &
3.4.2.1b. Another method (untested)
Use sudo to let secondary user launch x2x as the primary user on the primary display (with primary user's home directory)
In secondary user's $HOME/.xsessionrc
DISPLAY=:0 sudo -u primaryuser -to :1 -east
In /etc/sudoers
Defaults>primaryuser always_set_home Defaults:secondaryuser env_keep = "DISPLAY XAUTHORITY" secondaryuser ALL=(primaryuser) NOPASSWD: /usr/bin/x2x
4. Gotchas
- xscreensaver doesn't blank the screen on the primary display unless you have the mouse on the primary display before leaving things idle
- If you switch to a virtual terminal the secondary display will go blank and won't come back when you switch back
Copyright: Copyright 2009 Daniel F. Dickinson and any new contributors This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this file, if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.