Aug 25, 2013

Linux Mint Multiseat with keyboards & mice(Xephyr)

I must state this important fact first:

Xephyr on Ubuntu/Linux Mint does not come compiled with evdev support.

This is important because Linux uses evdev to configure most input devices like keyboards and mice. You will see lots of documentation on configuring inputs with evdev, but none of those methods will work unless you compile Xephyr from scratch and enable evdev yourself.

I downloaded and installed the following executable to make my life easier. I repeat, this method will not work unless you have a modified version of Xephyr with evdev support!

Correct drivers - make sure they are installed!

I used an older Nvidia card so the following commands got me up and running:
sudo apt-get -y xserver-xorg-video-nouveau
#
# Upgrade our system
sudo apt-get -y install ubuntu-drivers-common
sudo apt-get -y install nvidia-current nvidia-settings

If you are unsure what graphics card you have then run the following (the second line is my output; yours will probably be different):
$ lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GT218 [GeForce 210] (rev a2)

Input devices

Determine which devices are which by running the following command (unplug devices to help to narrow down your options). The paths you see are going to help in writing up our configuration file.

$ ls -l /dev/input/by-path/
total 0
lrwxrwxrwx 1 root root 9 May 27 18:39 pci-0000:00:1d.0-usb-0:1:1.0-event-kbd -> ../event3
lrwxrwxrwx 1 root root 9 May 27 18:39 pci-0000:00:1d.0-usb-0:2:1.0-event-mouse -> ../event4
lrwxrwxrwx 1 root root 9 May 27 18:39 pci-0000:00:1d.0-usb-0:2:1.0-mouse -> ../mouse0
lrwxrwxrwx 1 root root 9 May 27 18:39 platform-i8042-serio-0-event-kbd -> ../event2
lrwxrwxrwx 1 root root 9 May 27 18:39 platform-i8042-serio-1-event-mouse -> ../event5
lrwxrwxrwx 1 root root 9 May 27 18:39 platform-i8042-serio-1-mouse -> ../mouse1

Custom Xephyr script

The custom script (save it to /usr/sbin/Xephyr.sh) will act like the glue in our multi-seat environment. It will attach input devices to our monitors and some other stuff.

#!/bin/bash
# 20060905 - josean - added get_event() function to obtain eventNN from a physical address
# Original version:
# http://en.wikibooks.org/wiki/Multiterminal_with_Xephyr
# http://www.c3sl.ufpr.br/multiterminal/howtos/Xephyr.sh
trap "" usr1
XEPHYR=/usr/local/sbin/Xephyr
get_event()
{
    evento=`grep -A5 $1 /proc/bus/input/devices | grep 'H: Handlers=' | grep --only-matching -e 'event[0-9]*'`
}
args=()
while [ ! -z "$1" ]; do
    if [[ "$1" == "-xauthority" ]]; then
        shift
        if [ ! -z "$1" ]; then
            export XAUTHORITY="$1"
        fi
    elif [[ "$1" == "-display" ]]; then
        shift
        if [ ! -z "$1" ]; then
            export DISPLAY="$1"
        fi
    elif [[ "$1" == "-kbdphys" ]]; then
        shift
        if [ ! -z "$1" ]; then
            get_event $1
            args=("${args[@]}" "-keybd")
            args=("${args[@]}" "evdev,,device=/dev/input/$evento,xkbrules=evdev,xkbmodel=evdev,xkblayout=us")
        fi
    elif [[ "$1" == "-mousephys" ]]; then
        shift
        if [ ! -z "$1" ]; then
            get_event $1
            args=("${args[@]}" "-mouse")
            args=("${args[@]}" "evdev,5,device=/dev/input/$evento")
        fi
    else
        if ! expr match $1 'vt[0-9][0-9]*' >/dev/null; then
            args=("${args[@]}" "$1")
        fi
    fi
    shift
done
echo $XEPHYR "${args[@]}"
exec $XEPHYR "${args[@]}"

Xorg.conf settings

Edit /etc/X11/xorg.conf with something similar to the following. Please change the values to your whatever matches your system!!

############## SETTINGS#############
Section "ServerFlags"   Option  "DontZap"  "true"   Option  "DontVTSwitch" "true"   Option   "DontZoom" "true"   Option   "AllowMouseOpenFail"   "true"   Option   "AllowEmptyInput"   "true"   Option   "AutoAddDevices"   "false"   Option   "AutoEnableDevices"   "false"   Option  "Xinerama" "false"   Option   "NoPM" "true"   Option   "DPM" "false"   Option   "BlankTime" "0"   Option   "StandbyTime" "0"   Option   "SuspendTime" "0"   Option   "OffTime" "0"EndSection
############## INPUTS#############
Section "InputDevice"   Identifier   "Keyboard1"   Driver      "evdev"   Option      "Device" "/dev/input/event2"   Option      "Floating" "true"   Option      "XkbRules" "evdev"   Option       "XkbModel" "evdev"   Option      "XkbLayout" "us"EndSection
Section "InputDevice"   Identifier   "Mouse1"   Driver      "evdev"   Option      "Device" "/dev/input/event5"   Option      "Floating" "true"   Option      "GrabDevice" "on"   Option      "Protocol" "auto"   Option      "Emulate3Buttons" "no"   Option      "ZAxisMapping" "4 5"EndSection
Section "InputDevice"   Identifier   "Keyboard0"   Driver      "evdev"   Option      "Device" "/dev/input/event3"   Option      "Floating" "true"   Option      "XkbRules" "evdev"   Option      "XkbModel" "evdev"   Option      "XkbLayout" "us"EndSection
Section "InputDevice"   Identifier   "Mouse0"   Driver      "evdev"   Option      "Device" "/dev/input/event4"   Option      "Floating" "true"   Option      "GrabDevice" "on"   Option      "Protocol" "auto"   Option      "Emulate3Buttons" "no"   Option      "ZAxisMapping" "4 5"EndSection
########### SEAT 1##########
Section "Device"   Identifier   "Device1"   Driver      "nvidia"   Vendorname   "NVIDIA Corporation"   BoardName   "GeForce 210"   Option      "DPMS" "false"   Option      "UseDisplayDevice" "CRT"   Option      "ProbeAllGpus" "false"   Option      "NoLogo" "true"   Option      "RenderAccel" "true"   Screen      1EndSection
Section "Monitor"   Identifier   "Monitor1"   VendorName   "Toshiba"   ModelName   "Toshiba Matsushita Display Technology Co., Ltd LCD-MONITOR"   Option      "DPMS" "false"EndSection
Section "Screen"   Identifier   "Screen1"   Device      "Device1"   Monitor      "Monitor1"   DefaultDepth   24   Subsection "Display"      Depth   24      Modes   "nvidia-auto-select"   EndSubsection   Option      "DPMS" "false"   Option      "UseDisplayDevice" "CRT"   Option      "ProbeAllGpus" "false"EndSection
############# SEAT 0############
Section "Device"   Identifier   "Device0"   Driver      "nvidia"   VendorName   "NVIDIA Corporation"   BoardName   "GeForce 210"   Option      "DPMS" "false"   Option      "UseDisplayDevice" "DFP"   Option      "ProbeAllGpus" "false"   Option      "NoLogo" "true"   Option      "RenderAccel" "true"   Screen      0EndSection
Section "Monitor"   Identifier   "Monitor0"   VendorName   "Toshiba"   ModelName   "Toshiba Matsushita Display Technology Co., Ltd LCD-MONITOR"   Option      "DPMS" "false"EndSection
Section "Screen"   Identifier   "Screen0"   Device      "Device0"   Monitor      "Monitor0"   DefaultDepth   24   SubSection "Display"      Depth 24      Modes "nvidia-auto-select"   EndSubsection   Option      "DPMS" "false"   Option      "UseDisplayDevice" "DFP"   Option      "ProbeAllGpus" "false"EndSection
############## SERVERS#############
Section "ServerLayout"   Identifier   "multix"   Screen   0 "Screen0" 0 0   Screen   1 "Screen1" 0 0EndSection


MDM configuration

The MDM is what executes everything (if it has been configured properly). Edit /etc/mdm/mdm.conf and change the Server Section to the following:

## Also note, that if you redefine a [server-foo] section, then MDM will# use the definition in this file, not the MDM System Defaults configuration# file.  It is currently not possible to disable a [server-foo] section# defined in the MDM System Defaults configuration file.#
[server-Xephyr0]name=Xephyr0command=/usr/bin/X -ac -br -layout multix -audit 4 -dpmshandled=falseflexible=false
[server-Xephyr1]name=Xephyr1command=/usr/sbin/Xephyr.sh -display :0.0 -xauthority /var/lib/mdm/:0.Xauth -fullscreen -kbdphys usb-0000:00:1d.0-1/input0 -mousephys usb-0000:00:1d.0-2/input0 -verbosity 100 -audit 4 -screen 0 -dpms -retrohandled=trueflexible=false
[server-Xephyr2]name=Xephyr2command=/usr/sbin/Xephyr.sh -display :0.1 -xauthority /var/lib/mdm/:0.Xauth -fullscreen -kbdphys isa0060/serio0/input0 -mousephys isa0060/serio1/input0 -verbosity 100 -audit 4 -screen 1 -dpms -retrohandled=trueflexible=false

Resources

1 comment:

  1. I installed an Nvidia GT610 in my system and got a linux Mint 17 logo to appear on it (although I couldn't actually move my mouse to that screen). Then I started on your instructions for multiseat. First of all, on my system this command is not understood "sudo apt-get -y xserver-xorg-video-nouveau". I tried running it without the -y and it still rejected it. Since the 17.1 repository seems to include Xorg and Zephyr I just decided to try the driver update in case this card is too old. After I ran this command "sudo apt-get -y install nvidia-current nvidia-settings" the new monitor no longer shows up as an option in the Monitors panel. No signal. The video card does still show up in the lspci listing. It's not clear to me if I lost the correct drivers or if something else happened. Perhaps for multiseat I don't need to see it on this users desk anyway... Any thoughts?

    ReplyDelete

Thanks for contributing!! Try to keep on topic and please avoid flame wars!!