Configuring Multiseat to Dynamically Handle Mice and Keyboards using Udev

posted in: Blog, The Technology Minutiae | 0

At this point in my multiseat saga, I have multiseat working as I described in Hardware Accelerated NVidia and Intel Graphics Together in Debian. I was thrilled and expected that Brenda and I would go into production mode; each of us doing our thing with multiseat working flawlessly in the background. As the future would show, Brenda had a more realistic assessment of the achievements to-date and therefore decided to use her laptop instead. For her laptop, Brenda wanted the wireless keyboard that I had matched to her “seat,” so she unplugged it and took it. That essentially froze the login window on her seat so that even replugging the USB keyboard wireless dongle wouldn’t restore input access to the login window. Well, I continued to work in “my seat” and soon, my mouse stopped working. Unplugging the mouse and replugging it in didn’t restore mouse function. Fortunately, I was using the Xmonad graphical window manager, so the mouse was mostly optional.

For the moment, I ignored the input device problem and focused on the positive potential for our system. It was not yet clear to me if the Intel 3000 graphics on the CPU would support 3D. There is good support for 3D with the NVidia graphics adapter–NVidia really pushes for active 3D (with special battery powered glasses), but also supports passive 3D (simple glasses without batteries like we have with our ASUS IPS 3D monitor). The IPS monitor was currently hooked up to Brenda’s seat on the Intel graphics adapter, but if necessary, I could move her seat over to the NVidia graphics adapter. I didn’t want to do that if it wasn’t necessary because I would lose the ability to use the NVidia GPU in Mathematica if I were to use the Acer monitor/seat on the Intel graphics adapter. What I quickly discovered (after restarting X to get some input devices working) is that if I push the 3D button on the ASUS monitor, I can start Glxgears in 3D and it works without any custom options set in the xorg configuration files. Note that the monitor 3D button must be pushed before starting Glxgears in 3D. So, good news, passive 3D works on the Intel graphics adapter! That validated the seat assignments and I refocused on the reliability problems that seemed to be caused by static assignment of input devices to specific seats.

Most of the older how-to guides show using fixed addresses for the input devices. Current Linux distributions use Udev for pluggable devices and are therefore more flexible. After some Internet research into dynamic allocation of input devices using Udev, I rewrote the InputClass sections in xorg_intel.conf and xorg_nvidia and added another xorg configuration file in /etc/X11/xorg.conf.d with keyboard settings that are common to both seats. Now, Udev adds a tag to each input device that specifies which Xserver will use that device. First, we specify that a device claimed by another Xserver can not be used. Second, by default any device will go to the Intel Xserver :0, but anything connected to a USB hub near the Acer monitor is labeled “input_nvidia” and connected to the NVidia Xserver :1. Any input device can be removed, reconnected, or additional devices connected and everything continues to work–no more locked X-sessions due to lack of an input device.

There are many good how to manuals on the Internet, but it never hurts to add what I have done. Specifically:

1. Input device section in xorg_intel.conf

Section “InputClass”
Identifier “ignore_other_seats”
Option “Ignore” “yes”

Section “InputClass”
Identifier “input_default”
MatchTag “input_default”
Option “Ignore” “no”

2. Input device section in xorg_nvidia.conf

Section “InputClass”
Identifier “ignore_other_seats”
Option “Ignore” “yes”

Section “InputClass”
Identifier “input_nvidia”
MatchTag “input_nvidia”
Option “Ignore” “no”

3. I didn’t already have an xorg.conf.d directory, so I made it and created a new /etc/X11/xorg.conf.d/00-keylayouts.conf file with the following:

Section “InputClass”
Identifier “Default Layout”
MatchIsKeyboard “yes”
Option “XkbModel” “evdev”
Option “XkbLayout” “us”
Option “XkbOptions” “terminate:ctrl_alt_bksp”

4. Create a new Udev rule file /etc/udev/rules.d/99-seats.rules with the following:

SUBSYSTEM==”input”, ENV{ID_INPUT.tags}=”input_default”
SUBSYSTEM==”input”, DEVPATH==”/devices/pci0000:00/0000:00:1d.0/usb4/4-1/*”, ENV{ID_INPUT.tags}=”input_nvidia”

Note that the specific device address you use must be customized to your setup. The method I used started with the command:

ls -l /dev/input/by-id/

That returned a bunch of listings of input devices with names I could recognize. Specifically:

lrwxrwxrwx 1 root root 10 Jul 19 11:51 USB-A4Tech_RF_USB_Receiver-event-kbd -> ../event10
lrwxrwxrwx 1 root root 10 Jul 19 11:51 USB-A4Tech_RF_USB_Receiver-event-mouse -> ../event11
lrwxrwxrwx 1 root root 9 Jul 19 11:51 USB-A4Tech_RF_USB_Receiver-mouse -> ../mouse2
lrwxrwxrwx 1 root root 9 Jul 12 12:48 USB-Logitech_Logitech_Illuminated_Keyboard-event-if01 -> ../event7
lrwxrwxrwx 1 root root 9 Jul 12 12:48 USB-Logitech_Logitech_Illuminated_Keyboard-event-kbd -> ../event6
lrwxrwxrwx 1 root root 9 Jul 12 12:48 USB-Logitech_USB_Receiver-event-kbd -> ../event0
lrwxrwxrwx 1 root root 9 Jul 12 12:48 USB-Logitech_USB_Receiver-event-mouse -> ../event1
lrwxrwxrwx 1 root root 9 Jul 12 12:48 USB-Logitech_USB_Receiver-mouse -> ../mouse0
lrwxrwxrwx 1 root root 9 Jul 12 12:48 USB-Microsoft_Basic_Optical_Mouse-event-mouse -> ../event5
lrwxrwxrwx 1 root root 9 Jul 12 12:48 USB-Microsoft_Basic_Optical_Mouse-mouse -> ../mouse1

The Logitech Illuminated keyboard and Microsoft mouse are plugged into the hub near the NVidia computer and from that listing, those input devices are event5, event6, and event7. I next ran this command:

find /sys/devices/ -name event5

Which returned:


I repeated the above command for event6 and event7. I want to find the common root USB hub for the input devices. I actually used the hub just upstream of the one near the monitor which is in the computer case. As a result a couple of USB slots on the computer can be used for my seat. It won’t hurt to go up a level, as long as Brenda doesn’t attempt to use an input device in one of “my” slots.

At this point, I am once again thrilled. This is all part of the technology roller-coaster–most of my projects start with me really thrilled about some new capability, then I discover a depressing problem, and finally, I triumph with a fix. Brenda, however, is even more adamant that she will continue to use her laptop. She says that so much has happened that she wants everything to settle out before committing her work to an unreliable computer. I can’t believe she thinks my setup is unreliable–until I see the crashed Xserver when I wake up the next morning. It turns out she was right and my biggest challenge to getting a useful multiseat setup is still ahead of me. More to follow…

photo: Flickr 2006

Leave a Reply