1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/bin/bash
#Copyright (c) 2010 Lucas Nascimento Ferreira
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in
#all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.
# Takes the "seat name" as parameter $1
SEAT_NAME=$1
SEAT_NUMBER=${SEAT_NAME#seat}
CK_SESSIONS_DIR="/etc/ConsoleKit/sessions.d/"
CK_LIST_SESSION="/usr/bin/ck-list-sessions"
CK_SEAT_TOOL="/usr/sbin/ck-seat-tool"
XORG_CONF_USBSEAT="/etc/X11/xorg.conf.usbseat"
XORG_CONF_TMP="/tmp/xorg.conf.tmp"
echo "Udev Action: $ACTION" &>> /var/log/usbseat.log
if [ "$ACTION" == "remove" ]; then
echo "Removing $SEAT_NAME." &>> /var/log/usbseat.log
# Remove the lock, so now we can use this seat_id for start a new seat.
rm -f /tmp/$SEAT_NAME.lock
# The followling lines are commented because ConsoleKit daemon crashes if
# the usbseats are connected and disconected several times.
#
# SESSION_ID=`$CK_LIST_SESSION -a | grep -B3 usbseat$SEAT_NUMBER | head -n1`
# $CK_SEAT_TOOL -d --session-id ${SESSION_ID%\:} &>> /var/log/usbseat.log
echo "$SESSION_ID removed." &>> /var/log/usbseat.log
else
if [ -e /tmp/$SEAT_NAME.lock ]; then
echo "${SEAT_NAME} already exists." &>> /var/log/usbseat.log
exit 0
fi
# Check if we have a usefull seat.
if [[ -e /dev/usbseat/$SEAT_NAME/keyboard && -e /dev/usbseat/$SEAT_NAME/mouse && -e /dev/usbseat/$SEAT_NAME/display ]]; then
echo "Starting ${SEAT_NAME}" &>> /var/log/usbseat.log
# Every time a device is connected to a seat, this script will be
# called, so create a lock file for start the seat only when is
# necessary
touch /tmp/$SEAT_NAME.lock
# We have a newly complete seat. Start it.
sed "s/%ID_SEAT%/$SEAT_NAME/g" < $XORG_CONF_USBSEAT > $XORG_CONF_TMP
$CK_SEAT_TOOL -a --session-type usbseat --display-type usbseat --seat-id usbseat$SEAT_NUMBER &>> /var/log/usbseat.log
fi
fi
|