2

I have a powerful machine that I want to use as a multi-seat system. It has two graphic cards and two pairs of keyboards and mice. I've been able to successfully configure two "seats" using udev and Xorg.conf, and launch two X servers from a script so two users can have independent sessions. Just for the record, here's my udev rules file, where I identify each USB hub and label the devices and the seats:

SUBSYSTEM=="drm", KERNEL=="card[0-9]*", ATTRS{vendor}=="0x10de", DRIVERS=="nvidia", TAG+="master-of-seat"
# SUBSYSTEM=="drm", KERNEL=="card0", ENV{ID_SEAT}="seat0"
# SUBSYSTEM=="drm", KERNEL=="card1", ENV{ID_SEAT}="seat1"
SUBSYSTEM=="input", ENV{ID_INPUT.tags}="input_default"

# KVM HUBS
KERNELS=="3-2", ATTRS{bDeviceClass}=="09", ENV{KVM_HUB}="1", ENV{ID_SEAT}="seat0"
KERNELS=="3-8", ATTRS{bDeviceClass}=="09", ENV{KVM_HUB}="2", ENV{ID_SEAT}="seat1"

# Devices of HUB 1
KERNEL=="event*", ENV{KVM_HUB}=="1", ATTRS{bInterfaceProtocol}=="01" SYMLINK+="kvm_keyboard_1"
KERNEL=="event*", ENV{KVM_HUB}=="1", ATTRS{bInterfaceProtocol}=="02" SYMLINK+="kvm_mouse_1"

# Devices of HUB 2
KERNEL=="event*", ENV{KVM_HUB}=="2", ATTRS{bInterfaceProtocol}=="01" SYMLINK+="kvm_keyboard_2"
KERNEL=="event*", ENV{KVM_HUB}=="2", ATTRS{bInterfaceProtocol}=="02" SYMLINK+="kvm_mouse_2"

# Default seat
SUBSYSTEM=="input", TAG=="seat", ENV{ID_SEAT}=="" , ENV{ID_SEAT}="seat0"

# set all tags accordingly
ENV{ID_SEAT}!="", ENV{ID_INPUT.tags}+="$env{ID_SEAT}" TAG+="$env{ID_SEAT}"

The relevant part of my xorg.conf file looks like this:

Section "ServerFlags"
    # Option         "AutoAddDevices"      "false"
    # Option         "AutoEnableDevices"   "false"
    Option         "DefaultServerLayout" "Layout0"
    Option         "AllowMouseOpenFail"  "true"
    Option         "Xinerama" "0"
EndSection


# ---------------------------------------------------------------
# LAYOUT

Section "ServerLayout"
    Identifier     "Layout0"
    Screen         "Screen0"
    MatchSeat      "seat0"
    Option         "Clone"   "off"
EndSection

Section "ServerLayout"
    Identifier     "Layout1"
    Screen         "Screen1"
    MatchSeat      "seat1"
    Option         "Clone"   "off"
EndSection

As I said, I can successfully launch two independent sessions using the following script, but I'd like this to happen automatically on boot.

#!/bin/bash
set +x

rm /etc/X11/xorg.conf
cp ./xorg_independientes /etc/X11/xorg.conf

# X (:0)
systemctl stop gdm
killall Xorg
killall X
systemctl restart gdm

sleep 7

# X (:1)
su - sit -c "startx /usr/bin/gnome-session -- :1 vt4 -layout Layout1 -seat seat1 -sharevts" &
sleep 10
DISPLAY=:1 xhost +

My approach would be setting the default target runlevel to 4 (so it has everything but graphics) and then placing these commands in a script somewhere.

  • The usual place to start multiple X servers would be in the display manager (after all, that's the program responsible for start the X server). I'm using xdm, where /etc/X11/xdm/Xservers would be the file to edit, but I don't know how gdm does it. – dirkt Dec 12 '16 at 14:25
  • I'll eventually be using no display managers, just bare X servers. – José Tomás Tocino Dec 13 '16 at 7:25
  • Then I'd first try to do it without the display manager (deinstall it). X has options -config and -configdir if you want different config files. I'd guess you'd be able to start them as systemd services, under some target that corresponds to runlevel 4 (if you want to keep systemd). – dirkt Dec 13 '16 at 8:01
  • You might check out the loginctl command for systemd. It talks a lot about seats, though I don't know the details. – meuh Dec 13 '16 at 20:27
0

Starting in RHEL6, they use Upstart for starting processes at boot. In order to start two different X servers, create 2 separate scripts to start your X server on :0 and :1.

start_colon_0.sh:

#!/bin/sh
su - sit -c "startx -- :0 vt4 -layout Layout0 -seat seat0 -sharevts" &

start_colon_1.sh:

#!/bin/sh
su - sit -c "startx -- :1 vt4 -layout Layout1 -seat seat1 -sharevts" &

In /etc/init, create 2 configuration files as follows:

x_server_0.conf:

start on stopped rc RUNLEVEL=5
stop on starting rc RUNLEVEL=[!5]
console output
respawn
exec start_colon_0.sh

x_server_1.conf:

start on stopped rc RUNLEVEL=5
stop on starting rc RUNLEVEL=[!5]
console output
respawn
exec start_colon_1.sh

This will run your scripts at startup when entering runlevel 5.

See the Upstart tutorial

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.