#!/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