środa, 9 lutego 2011

Multiseat setup - match-and-name

. /etc/multiseat/scripts/helper-functions

EV=$1

#
# $1 device type
# $2 match table size
# $3 event interface id
# $4 device name
#
do_device()
{
    TABLE_NAME=$1
    T_SIZE=$2
    EVENT=$3
    NAME=$4
    # if match table empty then no match
    match=0
    for ((j = 0; j < $T_SIZE; j++)) {
            PATTERN=`get_table $i $TABLE_NAME $j`
            match=0
            /sbin/udevadm info --name=/dev/input/$EVENT --attribute-walk | grep 2>&1 "$PATTERN" >/dev/null || break
            match=1
    }
    if [ $match == 1 ];
    then
        echo $NAME
        return 0
    fi
    return 1
}

SEATS=`get_num_seats`

for ((i = 1; i <= $SEATS; i++)) {
    KEYB_T_SIZE=`get_table $i KEYBOARD_MATCH -size`
    KEYB=`get_conf $i KEYBOARD`
    do_device KEYBOARD_MATCH $KEYB_T_SIZE $EV $KEYB && exit 0

    MOUSE_T_SIZE=`get_table $i MOUSE_MATCH -size`
    MOUSE=`get_conf $i MOUSE`
    do_device MOUSE_MATCH $MOUSE_T_SIZE $EV $MOUSE && exit 0
}

exit 1

Brak komentarzy:

Prześlij komentarz