wtorek, 11 grudnia 2012
wtorek, 20 listopada 2012
Good news!
The Xephyr in xserver-xephyr 1.12.4-3 now contains a patch restoring correct command line parsing, so now only --enable-kdrive-evdev is required in the control file.
poniedziałek, 5 listopada 2012
Another upgrade
This time it is lightdm: the latest version in wheezy is 1.2.2-4.
The same procedure is still valid: apply the two patches, rebuild and voila.
The same procedure is still valid: apply the two patches, rebuild and voila.
środa, 24 października 2012
Still + 1
The latest Wheezy update as of this writing still contains a buggy Xephyr, version xorg-server-1.12.4. The patch
http://patchwork.freedesktop.org/patch/12146/
still needs to be applied. But Xephyr needs to be recompiled with -enable-kdrive-evdev anyway for our purposes, so applying this one-liner won't hurt. Other than that, it works fine.
http://patchwork.freedesktop.org/patch/12146/
still needs to be applied. But Xephyr needs to be recompiled with -enable-kdrive-evdev anyway for our purposes, so applying this one-liner won't hurt. Other than that, it works fine.
poniedziałek, 8 października 2012
Too much patch will kill you
In the recent Debian wheezy there is a new Xephyr which has broken options parsing due to a mismerged patch. The bug is fixed by Keith Packard, I will post more soon.
http://lists.debian.org/debian-x/2012/10/msg00071.html
http://patchwork.freedesktop.org/patch/12146/
Looks like the patch is not going to make it soon to Wheezy, so there you go, you can use the patch from freedesktop.
http://lists.debian.org/debian-x/2012/10/msg00071.html
http://patchwork.freedesktop.org/patch/12146/
Looks like the patch is not going to make it soon to Wheezy, so there you go, you can use the patch from freedesktop.
poniedziałek, 24 września 2012
helper-functions
. /etc/default/multiseat
#
# private implementation of get_sect
#
# get given section's contents from the given config file
#
# $1 filename
# $2 section number
#
__get_sect()
{
cat $1 | awk -v sect=$2 '
BEGIN {
SECT="^\\[" sect "\\]"
NEXT_SECT="^\\[" (sect + 1) "\\]"
}
$0 ~ SECT, $0 ~ NEXT_SECT {
if ($0 ~ SECT)
next;
if ($0 ~ NEXT_SECT)
next;
if (substr($1, 1, 1) == "#")
next;
print
}
'
}
#
# private implementation of get_conf
#
# get given key's contents from the given section
# from the given config file
#
# does not work for tables in the config file
#
# $1 filename
# $2 section name
# $3 key name
#
__get_conf()
{
__get_sect $1 $2 | awk -F"=" -v key=$3 '
BEGIN {
KEY=key
}
$1==KEY {
print substr($0, index($0, "=") + 1)
}
'
}
#
# private implementation of get_num_seats
#
# get number of seats from the default config file
#
# $1 filename
#
__get_num_seats()
{
cat $1 | awk '
BEGIN {
count=0
}
/^\[[0-9]*\]/ {count++}
END {
print count - 1
}
'
}
#
# get given section's contents from the default config file
#
# $1 section name
#
get_sect()
{
__get_sect $CONFIG $1
}
#
# private implementation of get_table
#
# $1 filename
# $2 section number
# $3 table name
# $4 size/entry switch [-size => size, <number> for entry]
#
__get_table()
{
SIZE=0;
ENTRY=-1
if [ $4 == "-size" ];
then
SIZE=1;
else
ENTRY=$4
fi
RESULT=`__get_sect $1 $2 | awk -v table=$3 -v get_size=$SIZE -v entry=$ENTRY '
BEGIN {
print BEGIn
TABLE=table "\\\=" "\\\("
GET_SIZE=get_size
ENTRY=entry
size=0
}
$0 ~ TABLE, /^\)/ {
if ($0 ~ TABLE)
next;
if ($0 ~ /^\)/)
next;
if (substr($1, 1, 1) == "#")
next;
if (get_size == 0 && size == entry){
print
exit
}
size++;
}
END {
if (get_size)
print size;
}
'`
RESULT=`echo $RESULT | sed 's/^[ \t]*//g'`
echo $RESULT
}
#
# get given key's contents from the given section
# from the default config file
#
# does not work for tables in the config file
#
# $1 section name
# $2 key name
#
get_conf()
{
__get_conf $CONFIG $1 $2
}
#
# get number of seats from the default config file
#
get_num_seats()
{
__get_num_seats $CONFIG
}
#
# get size of a given table in the given section of the config file or
# get specified entry of the table
#
# $1 section number
# $2 table name
# $3 size/entry switch [-size => size, <number> for entry]
#
get_table()
{
__get_table $CONFIG $1 $2 $3
}
#
# private implementation of get_sect
#
# get given section's contents from the given config file
#
# $1 filename
# $2 section number
#
__get_sect()
{
cat $1 | awk -v sect=$2 '
BEGIN {
SECT="^\\[" sect "\\]"
NEXT_SECT="^\\[" (sect + 1) "\\]"
}
$0 ~ SECT, $0 ~ NEXT_SECT {
if ($0 ~ SECT)
next;
if ($0 ~ NEXT_SECT)
next;
if (substr($1, 1, 1) == "#")
next;
}
'
}
#
# private implementation of get_conf
#
# get given key's contents from the given section
# from the given config file
#
# does not work for tables in the config file
#
# $1 filename
# $2 section name
# $3 key name
#
__get_conf()
{
__get_sect $1 $2 | awk -F"=" -v key=$3 '
BEGIN {
KEY=key
}
$1==KEY {
print substr($0, index($0, "=") + 1)
}
'
}
#
# private implementation of get_num_seats
#
# get number of seats from the default config file
#
# $1 filename
#
__get_num_seats()
{
cat $1 | awk '
BEGIN {
count=0
}
/^\[[0-9]*\]/ {count++}
END {
print count - 1
}
'
}
#
# get given section's contents from the default config file
#
# $1 section name
#
get_sect()
{
__get_sect $CONFIG $1
}
#
# private implementation of get_table
#
# $1 filename
# $2 section number
# $3 table name
# $4 size/entry switch [-size => size, <number> for entry]
#
__get_table()
{
SIZE=0;
ENTRY=-1
if [ $4 == "-size" ];
then
SIZE=1;
else
ENTRY=$4
fi
RESULT=`__get_sect $1 $2 | awk -v table=$3 -v get_size=$SIZE -v entry=$ENTRY '
BEGIN {
print BEGIn
TABLE=table "\\\=" "\\\("
GET_SIZE=get_size
ENTRY=entry
size=0
}
$0 ~ TABLE, /^\)/ {
if ($0 ~ TABLE)
next;
if ($0 ~ /^\)/)
next;
if (substr($1, 1, 1) == "#")
next;
if (get_size == 0 && size == entry){
exit
}
size++;
}
END {
if (get_size)
print size;
}
'`
RESULT=`echo $RESULT | sed 's/^[ \t]*//g'`
echo $RESULT
}
#
# get given key's contents from the given section
# from the default config file
#
# does not work for tables in the config file
#
# $1 section name
# $2 key name
#
get_conf()
{
__get_conf $CONFIG $1 $2
}
#
# get number of seats from the default config file
#
get_num_seats()
{
__get_num_seats $CONFIG
}
#
# get size of a given table in the given section of the config file or
# get specified entry of the table
#
# $1 section number
# $2 table name
# $3 size/entry switch [-size => size, <number> for entry]
#
get_table()
{
__get_table $CONFIG $1 $2 $3
}
Escape characters alive forever
The multiseat config is never managed once and for ever...
I wanted the scripts to be as little dependent as possible, so for parsing the multiseat.conf file I used only bash&sed&awk, no fancy tools like python. The helper-functions have been written in the mawk dialect of awk, and the awk found in Debian used to be mawk. Alas, no longer. So there are two options to consider: modify the helper-functions, so that mawk is used explicitly instead of awk (and make sure mawk is installed), or modify the helper-functions to speak gnu awk found in Debian now. I chose the second option. In fact only some escaping craziness differs. Instead of one backslash now two or three (!) are required here and there. You can find the new script here.
I wanted the scripts to be as little dependent as possible, so for parsing the multiseat.conf file I used only bash&sed&awk, no fancy tools like python. The helper-functions have been written in the mawk dialect of awk, and the awk found in Debian used to be mawk. Alas, no longer. So there are two options to consider: modify the helper-functions, so that mawk is used explicitly instead of awk (and make sure mawk is installed), or modify the helper-functions to speak gnu awk found in Debian now. I chose the second option. In fact only some escaping craziness differs. Instead of one backslash now two or three (!) are required here and there. You can find the new script here.
czwartek, 23 sierpnia 2012
Multiseat - final thoughts (so far)
Now I am happily running an up-to-date Debian Wheezy. However, some precautions must be made when upgrading. I wrote such a script:
#!/bin/bash
SENSITIVE="wmctrl xserver-xephyr lightdm policykit"
PACKAGES=`apt-get --dry-run dist-upgrade | awk '/^The following packages will be upgraded:/,/^[1-9]./' | tail -n +2 | head -n -1`
echo "Searching sensitive packages:"
echo
echo $SENSITIVE
echo
echo "in:"
echo
echo $PACKAGES
echo
FOUND=0
for i in $SENSITIVE; do
echo $PACKAGES | grep $i 2>&1 >/dev/null && echo Found: $i && FOUND=1
done
if [ $FOUND -eq 0 ]; then
echo No sensitive packages found in upgrade.
fi
The script can be run after apt-get update to see if any of the packages enumerated in "SENSITIVE" are to be upgraded this time. If yes, care must be taken.
Policy kit needs a paragraph of its own. At this moment Debian Wheezy comes with policykit-1 version 0.105. This is the last version in which the actions' permissions are customized using .pkla files. From 0.106 on (0.107 is the latest now) the format and naming of the directories and files has changed.
Another thing is systemd, which one day can become The Right Way of doing things.
SENSITIVE="wmctrl xserver-xephyr lightdm policykit"
PACKAGES=`apt-get --dry-run dist-upgrade | awk '/^The following packages will be upgraded:/,/^[1-9]./' | tail -n +2 | head -n -1`
echo "Searching sensitive packages:"
echo
echo $SENSITIVE
echo
echo "in:"
echo
echo $PACKAGES
echo
FOUND=0
for i in $SENSITIVE; do
echo $PACKAGES | grep $i 2>&1 >/dev/null && echo Found: $i && FOUND=1
done
if [ $FOUND -eq 0 ]; then
echo No sensitive packages found in upgrade.
fi
The script can be run after apt-get update to see if any of the packages enumerated in "SENSITIVE" are to be upgraded this time. If yes, care must be taken.
Policy kit needs a paragraph of its own. At this moment Debian Wheezy comes with policykit-1 version 0.105. This is the last version in which the actions' permissions are customized using .pkla files. From 0.106 on (0.107 is the latest now) the format and naming of the directories and files has changed.
Another thing is systemd, which one day can become The Right Way of doing things.
USB in multiseat
Here is how I configured my machine in order for users @ multiseat can mount USB drives.
First of all, in modern Debian distributions there is polkit-1. The policy kit infrastructure consists of, among others, a D-BUS service org.freedesktop.PolicyKit1 implemented as /usr/lib/policykit-1/polkitd. The service is used on behalf of user applications wanting to talk to privileged processes, the latter being described by so called actions stored in /usr/share/polkit-1/actions/. Policy kit's job is either to grant permission for an application to talk to a privileged process, or not. Each action, apart from the service it describes, provides default permissions for different kinds of sessions: active sessions, inactive sessions and any kind of sessions. For example, org.freedesktop.udisks.policy file contains descriptions of a number of actions related to disks (like mount/unmount and such).
It turns out, that of the n + 1 X sessions (Xinerama + n seats), only the Xinerama session happens to be ACTIVE. All other sessions, started through Xephyrs, are PASSIVE. And by default PASSIVE sessions are not allowed to mount USB drives, which is expressed by <allow_inactive>no</allow_inactive> in org.freedesktop.udisks.policy. Nor are they allowed to suspend the machine, see org.freedesktop.upower.policy. In different places advice can be found to edit .policy files. Don't! It is not the right way to do it. Instead, create files in /etc/polkit-1/localauthority/50-local.d/. I use the following two:
10-org.freedesktop.upower.pkla:
Identity=unix-group:storage
Action=org.freedesktop.udisks.change;org.freedesktop.udisks.drive-detach;org.freedesktop.udisks.drive-eject;org.freedesktop.udisks.filesystem-mount;org.freedesktop.udisks.filesystem-unmount-others
ResultAny=yes
ResultInactive=yes
ResultActive=yes
In order for this setup to work, the users in question must belong to groups power and storage.
I handle mounting USB drives manually, that is, in a file manager drives show up automatically after plugging in, but one of the users (each time it can be a different user) must explicitly mount them for him/herself. In LXDE's pcmanfm->Edit->Preferences->Volume management "Mount removable media automatically when they are inserted" and "Mount mountable volumes automatically on program startup" are unchecked. In other words, the multiseat users must collaborate to decide who mounts the newly inserted USB drive. If it were to happen automatically, the user whose file manager mounts the drive first wins the race. And race is not what we want here.
As you might have noticed, I use LXDE. Gnome-3 looks to heavy. And besides, with Xephyr's lack of GLX support, only the classic appearance is available, so I choose the lighter alternative.
First of all, in modern Debian distributions there is polkit-1. The policy kit infrastructure consists of, among others, a D-BUS service org.freedesktop.PolicyKit1 implemented as /usr/lib/policykit-1/polkitd. The service is used on behalf of user applications wanting to talk to privileged processes, the latter being described by so called actions stored in /usr/share/polkit-1/actions/. Policy kit's job is either to grant permission for an application to talk to a privileged process, or not. Each action, apart from the service it describes, provides default permissions for different kinds of sessions: active sessions, inactive sessions and any kind of sessions. For example, org.freedesktop.udisks.policy file contains descriptions of a number of actions related to disks (like mount/unmount and such).
It turns out, that of the n + 1 X sessions (Xinerama + n seats), only the Xinerama session happens to be ACTIVE. All other sessions, started through Xephyrs, are PASSIVE. And by default PASSIVE sessions are not allowed to mount USB drives, which is expressed by <allow_inactive>no</allow_inactive> in org.freedesktop.udisks.policy. Nor are they allowed to suspend the machine, see org.freedesktop.upower.policy. In different places advice can be found to edit .policy files. Don't! It is not the right way to do it. Instead, create files in /etc/polkit-1/localauthority/50-local.d/. I use the following two:
10-org.freedesktop.upower.pkla:
[Suspend/hibernate permissions]
Identity=unix-group:power
Action=org.freedesktop.upower.suspend
ResultAny=yes
ResultInactive=yes
ResultActive=yes
Identity=unix-group:power
Action=org.freedesktop.upower.suspend
ResultAny=yes
ResultInactive=yes
ResultActive=yes
20-org.freedesktop.udisks.pkla:
[Storage Permissions]Identity=unix-group:storage
Action=org.freedesktop.udisks.change;org.freedesktop.udisks.drive-detach;org.freedesktop.udisks.drive-eject;org.freedesktop.udisks.filesystem-mount;org.freedesktop.udisks.filesystem-unmount-others
ResultAny=yes
ResultInactive=yes
ResultActive=yes
In order for this setup to work, the users in question must belong to groups power and storage.
I handle mounting USB drives manually, that is, in a file manager drives show up automatically after plugging in, but one of the users (each time it can be a different user) must explicitly mount them for him/herself. In LXDE's pcmanfm->Edit->Preferences->Volume management "Mount removable media automatically when they are inserted" and "Mount mountable volumes automatically on program startup" are unchecked. In other words, the multiseat users must collaborate to decide who mounts the newly inserted USB drive. If it were to happen automatically, the user whose file manager mounts the drive first wins the race. And race is not what we want here.
As you might have noticed, I use LXDE. Gnome-3 looks to heavy. And besides, with Xephyr's lack of GLX support, only the classic appearance is available, so I choose the lighter alternative.
Debian Wheezy - on hard disk
I just wanted to let you know that as of today, 23rd August 2012, I am using the most up-to-date Debian Wheezy with lightdm and LXDE, installed to the hard disk of my computer. It just works.
sobota, 18 sierpnia 2012
Xephyr
Remember me complaining I was not Keith Packard?
I am still not ;P
But I am kind of closer to a good solution with an up-to-date Xephyr.
You know, at my Faculty of Electronics and Information Technology I in fact learnt just one thing, everything else follows from that: "It works better when turned on" (a small addendum to it is that "computerization of a mess makes a bigger mess"). And this (not being turned on) is the very reason of Wheezy's Xephyr not handling evdev protocol.
So how can it be turned on? Fortunately, it is fairly simple: do apt-get source xserver-xephyr, then apt-get buid-dep xserver-xephyr, and then edit xorg-server-<some numbers>/debian/rules: after --enable-kdrive \ add a new line which reads --enable-kdrive-evdev \.
Then dpkg-buildpackage -uc -us, after some 15 minutes the build stopped with an error regarding libGL; however in xorg-server-1.12.3/debian/xserver-xephyr/usr/bin/Xephyr there was a new Xephyr binary. I tested it and it works ok!
I know that this is a kind of a poor man's solution: the package should build nicely to the end. It is desired to at least know and understand why the build stops and whether it should worry us. Nevertheless, it seems that Xephyr should not be a showstopper for the multiseat config, that is, we are not forced to use a binary from an ancient distribution.
I am still not ;P
But I am kind of closer to a good solution with an up-to-date Xephyr.
You know, at my Faculty of Electronics and Information Technology I in fact learnt just one thing, everything else follows from that: "It works better when turned on" (a small addendum to it is that "computerization of a mess makes a bigger mess"). And this (not being turned on) is the very reason of Wheezy's Xephyr not handling evdev protocol.
So how can it be turned on? Fortunately, it is fairly simple: do apt-get source xserver-xephyr, then apt-get buid-dep xserver-xephyr, and then edit xorg-server-<some numbers>/debian/rules: after --enable-kdrive \ add a new line which reads --enable-kdrive-evdev \.
Then dpkg-buildpackage -uc -us, after some 15 minutes the build stopped with an error regarding libGL; however in xorg-server-1.12.3/debian/xserver-xephyr/usr/bin/Xephyr there was a new Xephyr binary. I tested it and it works ok!
I know that this is a kind of a poor man's solution: the package should build nicely to the end. It is desired to at least know and understand why the build stops and whether it should worry us. Nevertheless, it seems that Xephyr should not be a showstopper for the multiseat config, that is, we are not forced to use a binary from an ancient distribution.
Configuration of ligthdm 1.2
The configuration is pretty similar to that of lightdm 1.0. The changes are indicated in red.
/
|
+-/etc
| |
| +-/default
| | |
| | +-multiseat
| |
| +-/lightdm
| | |
| | +-lightdm.conf
| |
| +-/X11
| | |
| | +-xorg.conf
| |
| +-/init.d
| | |
| | +-multiseat
| |
| +-/udev
| | |
| | +-/rules.d
| | |
| | +-00-multiseat.rules
| |
| +-/multiseat
| |
| +-multiseat.conf
| |
| +-/scripts
| |
| +-helper-functions
| |
| +-match-and-name
| |
| |
| +-multiseat-greeter-<n>
| |
| +-fake-greeter
| |
| +-Xephyr-seat-1
| |
| +-Xephyr-seat-<n>
|
+-/usr
|
+-/share
|
+-/xgreeters
|
|
+-xinerama.desktop
The lithdm.conf is different than in lightdm 1.0, because it explicitly specifies a distinct xserver-command for each seat, the same with greeter-session.
The xserver-command for the seat <n> references its corresponding Xephyr-seat-<n> script, which, in turn, has its seat number hardcoded. The greeter-session for the seat <n> references its corresponding multiseat-greeter-<n>.desktop file, which has a hardcoded reference to its corresponding multiseat-greeter-<n>, which in, turn, has its seat number hardcoded.
The /etc/init.d/multiseat is changed now because it has a LSB-style header, making it suitable for a dependency-based boot. To create appropriate symlinks call
$ update-rc.d multiseat defaults
The lithdm.conf is different than in lightdm 1.0, because it explicitly specifies a distinct xserver-command for each seat, the same with greeter-session.
The xserver-command for the seat <n> references its corresponding Xephyr-seat-<n> script, which, in turn, has its seat number hardcoded. The greeter-session for the seat <n> references its corresponding multiseat-greeter-<n>.desktop file, which has a hardcoded reference to its corresponding multiseat-greeter-<n>, which in, turn, has its seat number hardcoded.
The /etc/init.d/multiseat is changed now because it has a LSB-style header, making it suitable for a dependency-based boot. To create appropriate symlinks call
$ update-rc.d multiseat defaults
Multiseat setup - multiseat-greeter-1.desktop
[Desktop Entry]
Name=LightDM GTK+ Greeter
Comment=This runs the GTK+ greeter, it should only be run from LightDM
Exec=/etc/multiseat/scripts/multiseat-greeter-1
Type=Application
X-Ubuntu-Gettext-Domain=lightdm
Name=LightDM GTK+ Greeter
Comment=This runs the GTK+ greeter, it should only be run from LightDM
Exec=/etc/multiseat/scripts/multiseat-greeter-1
Type=Application
X-Ubuntu-Gettext-Domain=lightdm
Multiseat setup - multiseat-greeter-1
#!/bin/bash
#
#multiseat wrapper around ligthdm greeter in order to position 1 Xephyr instance
#
. /etc/multiseat/scripts/helper-functions
PRIMARY=`get_conf 0 PRIMARY`
SEAT=1
if [ $SEAT != $PRIMARY ]; then
XEP=`XAUTHORITY=/var/run/lightdm/root/:0 xwininfo -root -children -display :0 | grep "Xephyr on :$SEAT" --max-count=1`;
XEPHYR_WIN_ID=`echo ${XEP} | cut -d' ' -f1`;
DISPLACEMENT=`get_conf $SEAT DISPLACEMENT`
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 wmctrl 2>&1 -v -i -r ${XEPHYR_WIN_ID} -e 0,${DISPLACEMENT},-1,-1;
fi
XAUTHORITY=/var/run/lightdm/root/:$SEAT
DISPLAY=:$SEAT
exec /usr/sbin/lightdm-gtk-greeter
#
#multiseat wrapper around ligthdm greeter in order to position 1 Xephyr instance
#
. /etc/multiseat/scripts/helper-functions
PRIMARY=`get_conf 0 PRIMARY`
SEAT=1
if [ $SEAT != $PRIMARY ]; then
XEP=`XAUTHORITY=/var/run/lightdm/root/:0 xwininfo -root -children -display :0 | grep "Xephyr on :$SEAT" --max-count=1`;
XEPHYR_WIN_ID=`echo ${XEP} | cut -d' ' -f1`;
DISPLACEMENT=`get_conf $SEAT DISPLACEMENT`
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 wmctrl 2>&1 -v -i -r ${XEPHYR_WIN_ID} -e 0,${DISPLACEMENT},-1,-1;
fi
XAUTHORITY=/var/run/lightdm/root/:$SEAT
DISPLAY=:$SEAT
exec /usr/sbin/lightdm-gtk-greeter
Multiseat setup - Xephyr-seat-1
#!/bin/bash
#
# $1 - display number of this Xephyr
. /etc/multiseat/scripts/helper-functions
trap "" usr1
XEPHYR=/root/Xephyr-new
export DISPLAY=:0
export XAUTHORITY=/var/run/lightdm/root/:0
SEAT=1
SIZE=`get_conf $SEAT SIZE`
KEYBOARD=`get_conf $SEAT KEYBOARD`
LAYOUT=`get_conf $SEAT LAYOUT`
MOUSE=`get_conf $SEAT MOUSE`
DPI=`get_conf $SEAT DPI`
exec $XEPHYR -retro -screen ${SIZE} -keybd evdev,,device=/dev/input/${KEYBOARD},xkbrules=evdev,xkbmodel=evdev,xkblayout=${LAYOUT} -mouse evdev,,device=/dev/input/${MOUSE} -dpi ${DPI} $1
#
# $1 - display number of this Xephyr
. /etc/multiseat/scripts/helper-functions
trap "" usr1
XEPHYR=/root/Xephyr-new
export DISPLAY=:0
export XAUTHORITY=/var/run/lightdm/root/:0
SEAT=1
SIZE=`get_conf $SEAT SIZE`
KEYBOARD=`get_conf $SEAT KEYBOARD`
LAYOUT=`get_conf $SEAT LAYOUT`
MOUSE=`get_conf $SEAT MOUSE`
DPI=`get_conf $SEAT DPI`
exec $XEPHYR -retro -screen ${SIZE} -keybd evdev,,device=/dev/input/${KEYBOARD},xkbrules=evdev,xkbmodel=evdev,xkblayout=${LAYOUT} -mouse evdev,,device=/dev/input/${MOUSE} -dpi ${DPI} $1
Multiseat setup - init.d/multiseat
#!/bin/sh
### BEGIN INIT INFO
# Provides: multiseat
# Required-Start: bootlogs
# Required-Stop:
# Default-Start: 1 2 3 4 5
# Default-Stop:
# Short-Description: Trigger udev rules
# Description: For some reason the rules for multiseat config need to be
# fired once more and later than at the very beginning.
### END INIT INFO
/sbin/udevadm trigger
### BEGIN INIT INFO
# Provides: multiseat
# Required-Start: bootlogs
# Required-Stop:
# Default-Start: 1 2 3 4 5
# Default-Stop:
# Short-Description: Trigger udev rules
# Description: For some reason the rules for multiseat config need to be
# fired once more and later than at the very beginning.
### END INIT INFO
/sbin/udevadm trigger
Multiseat setup - lightdm.conf
[LightDM]
greeter-user=root
user-authority-in-system-dir=false
common-vt=true
[SeatDefaults]
xserver-allow-tcp=false
greeter-hide-users=true
user-session=lightdm-xsession
session-wrapper=/etc/X11/Xsession
[Seat:0]
xserver-command=X -br -dpms -s 0 -novtswitch
greeter-session=xinerama
[Seat:1]
xserver-command=/etc/multiseat/scripts/Xephyr-seat-1
greeter-session=multiseat-greeter-1
[Seat:2]
xserver-command=/etc/multiseat/scripts/Xephyr-seat-2
greeter-session=multiseat-greeter-2
greeter-user=root
user-authority-in-system-dir=false
common-vt=true
[SeatDefaults]
xserver-allow-tcp=false
greeter-hide-users=true
user-session=lightdm-xsession
session-wrapper=/etc/X11/Xsession
[Seat:0]
xserver-command=X -br -dpms -s 0 -novtswitch
greeter-session=xinerama
[Seat:1]
xserver-command=/etc/multiseat/scripts/Xephyr-seat-1
greeter-session=multiseat-greeter-1
[Seat:2]
xserver-command=/etc/multiseat/scripts/Xephyr-seat-2
greeter-session=multiseat-greeter-2
lightdm 1.2, debian Wheezy
The time has come and lightdm 1.2 is in Wheezy. There is no way but making it work. The good news is that I did it; I have a working system prepared as a customized Debian Live on a USB stick. The not so good news (but not so terribly bad either) is that the configuration is a little less elegant. However, there are only 2 small patches to lightdm to make it work. Actually, these are the same as the first 2 patches out of the 4 used in lightdm 1.0.
Here is the story: the 2 patches deal with removing unused lock files from /tmp (their presence influences the choice of the display number in subsequent runs of lightdm) and with adding an option to use the same vt for all X servers. This is the same as with lightdm 1.0. The difference is that the 2 remaining patches have not been applied. They don't apply at all, they are not even close, because the architecture of lightdm changed since 1.0 and the processes are started in a different way while the 2 remaining patches added an option to pass seat numbers to X servers and to greeters; both X servers and greeters are started as new processes. But there is a satisfying workaround: do not even try applying them, the trade-off being a less elegant configuration.
In the lightdm 1.0 solution there is one central multiseat.conf, which is used both by udev to name event interface nodes in /dev/input and by multiseat scripts to associate keyboards/mice with seats and to move X servers into their corresponding positions within one big Xinerama screen. The multiseat scripts were generic, so they needed to be told (in an invocation parameter) which seat they relate to; the solution was also nicely scalable - there was only one file, the multiseat.conf, which needed to be edited to specify the keyboards/mice matching to their seats. In the lightdm 1.2 solution the scripts cannot be told which seat they relate to (because lightdm is not patched to do so, for the reasons explained earlier), so some of them are copied, in as many instances as there are seats, and by their construction they relate to a fixed seat. The good thing is that the patches which have been applied are really simple, so it might be easier to make it to the lightdm mainline.
You can get the changes from here:
bzr branch lp:~andrzejtp2010/lightdm/lightdm-1.2-xephyr-multiseat
bzr diff -r1493 > multiseat.patch
and follow the build instruction from here.
Stay tuned.
Here is the story: the 2 patches deal with removing unused lock files from /tmp (their presence influences the choice of the display number in subsequent runs of lightdm) and with adding an option to use the same vt for all X servers. This is the same as with lightdm 1.0. The difference is that the 2 remaining patches have not been applied. They don't apply at all, they are not even close, because the architecture of lightdm changed since 1.0 and the processes are started in a different way while the 2 remaining patches added an option to pass seat numbers to X servers and to greeters; both X servers and greeters are started as new processes. But there is a satisfying workaround: do not even try applying them, the trade-off being a less elegant configuration.
In the lightdm 1.0 solution there is one central multiseat.conf, which is used both by udev to name event interface nodes in /dev/input and by multiseat scripts to associate keyboards/mice with seats and to move X servers into their corresponding positions within one big Xinerama screen. The multiseat scripts were generic, so they needed to be told (in an invocation parameter) which seat they relate to; the solution was also nicely scalable - there was only one file, the multiseat.conf, which needed to be edited to specify the keyboards/mice matching to their seats. In the lightdm 1.2 solution the scripts cannot be told which seat they relate to (because lightdm is not patched to do so, for the reasons explained earlier), so some of them are copied, in as many instances as there are seats, and by their construction they relate to a fixed seat. The good thing is that the patches which have been applied are really simple, so it might be easier to make it to the lightdm mainline.
You can get the changes from here:
bzr branch lp:~andrzejtp2010/lightdm/lightdm-1.2-xephyr-multiseat
bzr diff -r1493 > multiseat.patch
and follow the build instruction from here.
Stay tuned.
piątek, 25 maja 2012
Multiseat setup - Configuring lightdm
There are two pieces of information: a good one and a bad one. The good one is that I did successfully run a Xephyr-based multiseat setup using lightdm as display manager. The bad one is that I managed to modify lightdm from the 1.0 series. It is happily found in Debian wheezy now, but newer releases will likely make it into testing eventually.
Anyway, lets get to configuring it!
The tree of the installed files looks very similar to the layout used for gdm2. The changed/modified entries are indicated in red.
/
|
+-/etc
| |
| +-/default
| | |
| | +-multiseat
| |
| +-/lightdm
| | |
| | +-lightdm.conf
| |
| +-/X11
| | |
| | +-xorg.conf
| |
| +-/init.d
| | |
| | +-multiseat
| |
| +-/udev
| | |
| | +-/rules.d
| | |
| | +-00-multiseat.rules
| |
| +-/multiseat
| |
| +-multiseat.conf
| |
| +-/scripts
| |
| +-helper-functions
| |
| +-match-and-name
| |
| +-multiseat-greeter
| |
| +-fake-greeter
| |
| +-Xephyr-seat
|
+-/usr
Now let me explain the files.
lightdm.conf uses the three options added by the patches found on the branch in Launchpad. In [LightDM] there is common-vt=true. It means that all the X servers will use the same vt number. Since in a multiseat setup there are at least two seats, I used a convention that the default seat options are for the Xephyr seats proper, while the X server which covers all the monitors will use a dedicated configuration section of its own. The xserver-pass-seat-name=true option means that the command used to start the X server (xserver-command) will be added a parameter whose value is the number of the DISPLAY for this X instance. The greeter-pass-seat-id=true means that the command used to start the greeter (found in the Exec entry of the .desktop file) will be added parameters whose values are the number of the DISPLAY for this X instance and the seat name as found in lightdm.conf. E.g., if there are [Seat:1] and [Seat:2], then the seat names will be 1 and 2. Thanks to the greeter-pass-seat-id=true option the multiseat-greeter is simpler and it moves only the Xephyr of interest to its desired position. The Xauthority files are also different than in the gdm-based setup. The fake-greeter just sleeps. But, in order to cleanly shut down, it handles the TERM signal and kills the sleep command if a signal is received. Thanks to the xserver-pass-seat-name=true option the Xephyr-seat is also a bit simpler, as it expects seat name and display number as parameters. The desktop files are used to specify the command to be run as a greeter.
The fake greeter is a kind of a hack. In fact it would be best to force lightdm not to start a greeter at all, just X server.
All works similar to the gdm2 case. Only the configuration of the display manager and location and names of Xauthority files are different.
Anyway, lets get to configuring it!
The tree of the installed files looks very similar to the layout used for gdm2. The changed/modified entries are indicated in red.
/
|
+-/etc
| |
| +-/default
| | |
| | +-multiseat
| |
| +-/lightdm
| | |
| | +-lightdm.conf
| |
| +-/X11
| | |
| | +-xorg.conf
| |
| +-/init.d
| | |
| | +-multiseat
| |
| +-/udev
| | |
| | +-/rules.d
| | |
| | +-00-multiseat.rules
| |
| +-/multiseat
| |
| +-multiseat.conf
| |
| +-/scripts
| |
| +-helper-functions
| |
| +-match-and-name
| |
| +-multiseat-greeter
| |
| +-fake-greeter
| |
| +-Xephyr-seat
|
+-/usr
|
+-/share
|
+-/xgreeters
|
|
Now let me explain the files.
lightdm.conf uses the three options added by the patches found on the branch in Launchpad. In [LightDM] there is common-vt=true. It means that all the X servers will use the same vt number. Since in a multiseat setup there are at least two seats, I used a convention that the default seat options are for the Xephyr seats proper, while the X server which covers all the monitors will use a dedicated configuration section of its own. The xserver-pass-seat-name=true option means that the command used to start the X server (xserver-command) will be added a parameter whose value is the number of the DISPLAY for this X instance. The greeter-pass-seat-id=true means that the command used to start the greeter (found in the Exec entry of the .desktop file) will be added parameters whose values are the number of the DISPLAY for this X instance and the seat name as found in lightdm.conf. E.g., if there are [Seat:1] and [Seat:2], then the seat names will be 1 and 2. Thanks to the greeter-pass-seat-id=true option the multiseat-greeter is simpler and it moves only the Xephyr of interest to its desired position. The Xauthority files are also different than in the gdm-based setup. The fake-greeter just sleeps. But, in order to cleanly shut down, it handles the TERM signal and kills the sleep command if a signal is received. Thanks to the xserver-pass-seat-name=true option the Xephyr-seat is also a bit simpler, as it expects seat name and display number as parameters. The desktop files are used to specify the command to be run as a greeter.
The fake greeter is a kind of a hack. In fact it would be best to force lightdm not to start a greeter at all, just X server.
All works similar to the gdm2 case. Only the configuration of the display manager and location and names of Xauthority files are different.
Multiseat setup - lightdm.conf
[LightDM]
greeter-user=root
user-authority-in-system-dir=false
common-vt=true
[SeatDefaults]
xserver-command=/etc/multiseat/scripts/Xephyr-seat
xserver-allow-tcp=false
xserver-pass-seat-name=true
greeter-pass-seat-id=true
greeter-hide-users=true
greeter-session=multiseat-greeter
user-session=lightdm-xsession
session-wrapper=/etc/X11/Xsession
[Seat:0]
xserver-command=X -br -dpms -s 0 -novtswitch
xserver-pass-seat-name=false
greeter-pass-seat-id=false
greeter-session=xinerama
[Seat:1]
[Seat:2]
greeter-user=root
user-authority-in-system-dir=false
common-vt=true
[SeatDefaults]
xserver-command=/etc/multiseat/scripts/Xephyr-seat
xserver-allow-tcp=false
xserver-pass-seat-name=true
greeter-pass-seat-id=true
greeter-hide-users=true
greeter-session=multiseat-greeter
user-session=lightdm-xsession
session-wrapper=/etc/X11/Xsession
[Seat:0]
xserver-command=X -br -dpms -s 0 -novtswitch
xserver-pass-seat-name=false
greeter-pass-seat-id=false
greeter-session=xinerama
[Seat:1]
[Seat:2]
Multiseat setup - multiseat-greeter.desktop
[Desktop Entry]
Name=LightDM GTK+ Greeter
Comment=This runs the GTK+ greeter, it should only be run from LightDM
Exec=/etc/multiseat/scripts/multiseat-greeter
Type=Application
X-Ubuntu-Gettext-Domain=lightdm
Name=LightDM GTK+ Greeter
Comment=This runs the GTK+ greeter, it should only be run from LightDM
Exec=/etc/multiseat/scripts/multiseat-greeter
Type=Application
X-Ubuntu-Gettext-Domain=lightdm
Multiseat setup - xinerama.desktop
[Desktop Entry]
Name=LightDM Placeholder Greeter
Comment=This runs no greeter at all, it should only be run from LightDM
Exec=/etc/multiseat/scripts/fake-greeter
Type=Application
X-Ubuntu-Gettext-Domain=lightdm
Name=LightDM Placeholder Greeter
Comment=This runs no greeter at all, it should only be run from LightDM
Exec=/etc/multiseat/scripts/fake-greeter
Type=Application
X-Ubuntu-Gettext-Domain=lightdm
Multiseat setup - fake-greeter
#!/bin/bash
pid_set=0
kill_sleep()
{
if [ $pid_set -ne 0 ];
then
kill -15 $pid
fi
exit 0
}
trap 'kill_sleep' TERM
while true;
do
sleep 1000 &
pid=$!
pid_set=1
wait $pid
done
pid_set=0
kill_sleep()
{
if [ $pid_set -ne 0 ];
then
kill -15 $pid
fi
exit 0
}
trap 'kill_sleep' TERM
while true;
do
sleep 1000 &
pid=$!
pid_set=1
wait $pid
done
Multiseat setup - multiseat-greeter
#!/bin/bash
#
#multiseat wrapper around ligthdm greeter in order to position each Xephyr instance
#
. /etc/multiseat/scripts/helper-functions
PRIMARY=`get_conf 0 PRIMARY`
SEAT=$1
if [ $SEAT != $PRIMARY ]; then
XEP=`XAUTHORITY=/var/run/lightdm/root/:0 xwininfo -root -children -display :0 | grep "Xephyr on :$SEAT" --max-count=1`;
XEPHYR_WIN_ID=`echo ${XEP} | cut -d' ' -f1`;
DISPLACEMENT=`get_conf $SEAT DISPLACEMENT`
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 wmctrl 2>&1 -v -i -r ${XEPHYR_WIN_ID} -e 0,${DISPLACEMENT},-1,-1;
fi
XAUTHORITY=/var/run/lightdm/root/:$2
DISPLAY=:$2
exec /usr/sbin/lightdm-gtk-greeter
#
#multiseat wrapper around ligthdm greeter in order to position each Xephyr instance
#
. /etc/multiseat/scripts/helper-functions
PRIMARY=`get_conf 0 PRIMARY`
SEAT=$1
if [ $SEAT != $PRIMARY ]; then
XEP=`XAUTHORITY=/var/run/lightdm/root/:0 xwininfo -root -children -display :0 | grep "Xephyr on :$SEAT" --max-count=1`;
XEPHYR_WIN_ID=`echo ${XEP} | cut -d' ' -f1`;
DISPLACEMENT=`get_conf $SEAT DISPLACEMENT`
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 wmctrl 2>&1 -v -i -r ${XEPHYR_WIN_ID} -e 0,${DISPLACEMENT},-1,-1;
fi
XAUTHORITY=/var/run/lightdm/root/:$2
DISPLAY=:$2
exec /usr/sbin/lightdm-gtk-greeter
Multiseat setup - Xephyr-seat
#!/bin/bash
#
# $1 - seat name of this Xephyr (from Seat:<n> in lightdm.conf)
# $2 - display number of this Xephyr
. /etc/multiseat/scripts/helper-functions
trap "" usr1
XEPHYR=/root/Xephyr
export DISPLAY=:0
export XAUTHORITY=/var/run/lightdm/root/:0
SEAT=$1
SIZE=`get_conf $SEAT SIZE`
KEYBOARD=`get_conf $SEAT KEYBOARD`
LAYOUT=`get_conf $SEAT LAYOUT`
MOUSE=`get_conf $SEAT MOUSE`
DPI=`get_conf $SEAT DPI`
exec $XEPHYR -retro -screen ${SIZE} -keybd evdev,,device=/dev/input/${KEYBOARD},xkbrules=evdev,xkbmodel=evdev,xkblayout=${LAYOUT} -mouse evdev,,device=/dev/input/${MOUSE} -dpi ${DPI} $2
#
# $1 - seat name of this Xephyr (from Seat:<n> in lightdm.conf)
# $2 - display number of this Xephyr
. /etc/multiseat/scripts/helper-functions
trap "" usr1
XEPHYR=/root/Xephyr
export DISPLAY=:0
export XAUTHORITY=/var/run/lightdm/root/:0
SEAT=$1
SIZE=`get_conf $SEAT SIZE`
KEYBOARD=`get_conf $SEAT KEYBOARD`
LAYOUT=`get_conf $SEAT LAYOUT`
MOUSE=`get_conf $SEAT MOUSE`
DPI=`get_conf $SEAT DPI`
exec $XEPHYR -retro -screen ${SIZE} -keybd evdev,,device=/dev/input/${KEYBOARD},xkbrules=evdev,xkbmodel=evdev,xkblayout=${LAYOUT} -mouse evdev,,device=/dev/input/${MOUSE} -dpi ${DPI} $2
gdm3 sucks!
So I really wanted to configure gdm3 for multiseat. Anyone knows how gdm3 is configured? Finding a manual for that seems a holy grail. And the gazillion of configuration files it requires is just too intimidating. Paraphrazing a saying about emacs, one could say that gdm3 is a fairly good operating system, it only lacks a decent display manager. So I decided I would give lightdm a try.
In Debian wheezy as of this writing there is lightdm 1.0.11. It does not have a good documentation either and I didn't manage to configure it out of the box. But, as its authors declare, it is of "low code complexity". Well, I did delve into the source code.
The result is promising. I am able to run two Xephyr seats now. Only the Xephyr currently found in wheezy (1.12.1-2) does not seem to support the "evdev" protocol for keyboard and mouse. That's too bad. I have to use an older binary from 1.7.7-11. Or do I? Anyone knows about Xephyr? My name is not Keith Packard...
You can browse the source code here. You can also fetch it using bazaar. Why bazaar? I use git for everyday work. Bazaar seems bazzare to me ;) But they use it on Launchpad. So what can you do? Here is a command which fetches the code from Launchpad
bzr branch lp:~andrzejtp2010/lightdm/lightdm-1.0-xephyr-multiseat
There is also a lightdm-xephyr-multiseat branch, but, at least now, it is no good.
autogen.sh, configure, make and enjoy! Or, if you prefer to build it the debian way, you can. It is even perhaps easier in a way. But first you need a patch. The easiest way is to fetch the source from Launchpad, and then generate a patch:
bzr diff -r1307 > multiseat.patch
And then something on the lines of:
apt-get source lightdm
sudo apt-get build-dep lightdm
dch -l 'Xephyr-based multiseat revision'
patch -p1 < multiseat.patch (mind the directory you are in)
dpkg-source -commit
debuild -uc -us
And there you go. You can install the package. Alternatively, it is just enough to only copy the resulting binary from your newly built package into /usr/sbin. Voila!
But how to configure it for multiseat? Stay tuned.
niedziela, 19 lutego 2012
One year later
The multi (multi == 2) seat setup as described earlier has been working very well for the last year. However, I refrained from upgrading. Just in case.
One more thing I forgot to mention - in my setup the kernel mode setting is OFF, using "nomodeset" kernel command line parameter.
I am going to set up a test system on a separate hard disk and each time I want to upgrade, I will upgrade the test system first. If it works, the system proper should work, too.
One more thing I forgot to mention - in my setup the kernel mode setting is OFF, using "nomodeset" kernel command line parameter.
I am going to set up a test system on a separate hard disk and each time I want to upgrade, I will upgrade the test system first. If it works, the system proper should work, too.
Subskrybuj:
Posty (Atom)