Here’s how to add audio support on top of the previous instructions for getting USB multiseat running on Linux, with a Plugable UD-160-A type device.
Add the following line to the bottom of the /lib/udev/rules.d/50-usbseat.rules file created per the previous instructions.
KERNEL=="control*", SUBSYSTEM=="sound", SUBSYSTEMS=="usb", PROGRAM="/bin/cat /sys/%p/../../../../../devnum", SYMLINK+="usbseat/%c/sound"
Then create a new /etc/X11/Xsession.d/50usbseat file which will be run at Xsession create time, with the following contents
oldIFS=$IFS IFS=: set $DISPLAY IFS=. set $2 SEAT_ID=$1 LN=`ls -al /dev/usbseat/$SEAT_ID/sound` IFS=C set $LN CARD_ID=$2 export ALSA_CARD=$2 export ALSA_PCM_CARD=$2 IFS=$oldIFS
Each of the users who might need access to the USB devices needs to be added to the ‘audio’ group. On Ubuntu 9.04, this can be done with these commands to backup and then modify the groups (replace MY_USERNAME, of course) …
sudo cp /etc/group /etc/group_backup sudo chmod a-wx /etc/group_backup sudo adduser MY_USERNAME audio
See Ubuntu Sound TroubleShooting for details on that step.
Now, as you connect UD-160-A terminals, a new X instance and GDM login will pop up as before, but also each of them will have /dev/usbseat/%SEAT_ID%/sound linking to their sound device, and the ALSA_CARD environment variable for all processes off of that X session, set to the matching sound card ID. For apps which support ALSA/Pulse (like most browsers, flash, etc.), audio will now come out the correct terminal — all in a completely plug-and-play fashion.
If you’re wondering what the strange IFS stuff is in the above script, it’s bash’s built-in Internal Field Separator variable, which is an easy way to split strings without having to launch a separate sed or awk process.
Note, as before, these instructions are specific to and tested on an older version of Ubuntu: 9.04, and may need to be ported to other distros until the distros themselves integrate these scripts.
Thanks to Alexander Todorov’s earlier work on multiseat sound support, which demonstrated how to match the USB audio devices in udev, and which ALSA_ environment variables to set. Alexander reported some problems reliably matching the audio devices, but with these scripts (with limited testing so far), things are working as expected.