diff options
author | Paulo R. Zanoni <paulo@c3sl.ufpr.br> | 2008-08-26 06:59:58 -0300 |
---|---|---|
committer | Paulo R. Zanoni <paulo@c3sl.ufpr.br> | 2008-08-26 06:59:58 -0300 |
commit | 429c12fcd342372e70f4875a303397d16a47d615 (patch) | |
tree | ecec565ae1a2ef4a2ef4b742b4668d3a0f73e507 | |
parent | ff9caf48131436a22d334daa3bb50d883c5d5e9e (diff) |
Revert "There is a new variable being used: XEPHYR_NUMBER, which"
This reverts commit c3df780bb0550760db35c40698b9ee7706486c6e.
-rwxr-xr-x | mdm/src/mdm-start-seat | 96 |
1 files changed, 42 insertions, 54 deletions
diff --git a/mdm/src/mdm-start-seat b/mdm/src/mdm-start-seat index 1d5d694..968d6a3 100755 --- a/mdm/src/mdm-start-seat +++ b/mdm/src/mdm-start-seat @@ -32,27 +32,19 @@ READ_DEVICES=${MDM_SCRIPTS}/read-devices WRITE_MESSAGE=${MDM_SCRIPTS}/write-message SEAT_PARENT_WINDOW=${MDM_SCRIPTS}/seat-parent-window -# IMPORTANT! Seat number is the seat on wich -# heads will be raised on. SEAT_NUMBER=$1 -# IMPORTANT! This is the number that xephyr will have, -# consider that with a dual video card, we can make two heads. -# It is possible to have N Xephyrs on a N output video card. -XEPHYR_NUMBER=$2 - #MY_LOG=$MDM_LOGS/mdm-start-seat.${SEAT_NUMBER}.log function open_seat_parent_window () { - kill `cat ${MDM_PIDS}/seat-parent-window${DISPLAY}-$1.pid 2> /dev/null` - rm -f ${MDM_PIDS}/seat-parent-window${DISPLAY}-$1.pid 2> /dev/null - - $SEAT_PARENT_WINDOW $MY_SCREEN_SIZE+$1+0 seat-parent-window${DISPLAY}-$1 & - PID=$! - echo $PID > ${MDM_PIDS}/seat-parent-window${DISPLAY}-$1.pid - SEAT_WINDOW_ID=$(xwininfo -name "seat-parent-window${DISPLAY}-$1" | - grep "Window id" | - cut -d' ' -f4) + kill `cat ${MDM_PIDS}/seat-parent-window${DISPLAY}.pid 2> /dev/null` + rm -f ${MDM_PIDS}/seat-parent-window${DISPLAY}.pid 2> /dev/null + + $SEAT_PARENT_WINDOW $MY_SCREEN_SIZE+0+0 seat-parent-window$DISPLAY & + PID=$! + echo $PID > ${MDM_PIDS}/seat-parent-window${DISPLAY}.pid + + SEAT_WINDOW_ID=$(xwininfo -name "seat-parent-window${DISPLAY}" | grep "Window id" | cut -d' ' -f4) } @@ -77,17 +69,17 @@ function display_message () { function parse_config_file () { - if [ ! -z "${XKB_MODEL[SEAT_NUMBER]}" ]; then + if [ ! -z ${XKB_MODEL[SEAT_NUMBER]} ]; then MY_XKB_MODEL=${XKB_MODEL[SEAT_NUMBER]} else MY_XKB_MODEL=$DEFAULT_XKB_MODEL fi - if [ ! -z "${XKB_LAYOUT[SEAT_NUMBER]}" ]; then + if [ ! -z ${XKB_LAYOUT[SEAT_NUMBER]} ]; then MY_XKB_LAYOUT=${XKB_LAYOUT[SEAT_NUMBER]} else MY_XKB_LAYOUT=$DEFAULT_XKB_LAYOUT fi - if [ ! -z "${MODE[SEAT_NUMBER]}" ]; then + if [ ! -z ${MODE[SEAT_NUBMER]} ]; then MY_SCREEN_SIZE=${MODE[SEAT_NUMBER]} else MY_SCREEN_SIZE=$DEFAULT_MODE @@ -96,11 +88,11 @@ function parse_config_file () { } function select_keyboard () { - if [ -e "${MDM_DEVICES}/keyboard${XEPHYR_NUMBER}" ]; then + if [ -e "${MDM_DEVICES}/keyboard${SEAT_NUMBER}" ]; then return fi - display_message key_press $XEPHYR_NUMBER + display_message key_press $SEAT_NUMBER CREATED=0 while (( ! CREATED )); do @@ -109,7 +101,7 @@ function select_keyboard () { #echo " Keyboards = $KEYBOARDS" 1>&2 # Remove used keyboards - REMOVE=$(stat -c %N ${MDM_DEVICES}/keyboard* 2> /dev/null| + REMOVE=$(stat -c %N $MDM_DEVICES/keyboard* 2> /dev/null| cut -d'`' -f3 | cut -d"'" -f1) for i in ${REMOVE}; do KEYBOARDS=`sed "s#$i# #g" <<< $KEYBOARDS` @@ -118,13 +110,12 @@ function select_keyboard () { if [ -z "$KEYBOARDS" ]; then # No keyboards. Hopefully someone will connect one. - sleep 10 # Don't use 100% CPU + sleep 1 # Don't use 100% CPU continue fi # See if someone presses the key: - PRESSED=$($READ_DEVICES $XEPHYR_NUMBER $KEYBOARDS | - grep '^detect' | cut -d'|' -f2) + PRESSED=$($READ_DEVICES $SEAT_NUMBER $KEYBOARDS | grep '^detect' | cut -d'|' -f2) if [ -z "$PRESSED" ]; then # if $READ_DEVICES gets killed the script won't do bad stuff @@ -135,30 +126,30 @@ function select_keyboard () { fi # Ok, someone pressed the key - ln -sf $PRESSED ${MDM_DEVICES}/keyboard${XEPHYR_NUMBER} + ln -sf $PRESSED $MDM_DEVICES/keyboard${SEAT_NUMBER} CREATED=1 # Verify is there is already another link in $MDM_DEVICES/keyboard* that # points to the device. If there is, erase the one I created and # continue looping for i in `ls $MDM_DEVICES | grep "\<keyboard"`; do - if [ "$i" != "keyboard${XEPHYR_NUMBER}" ]; then - AUX=$(stat -c %N ${MDM_DEVICES}/$i| cut -d'`' -f3| cut -d"'" -f1) + if [ "$i" != "keyboard${SEAT_NUMBER}" ]; then + AUX=$(stat -c %N $MDM_DEVICES/$i| cut -d'`' -f3| cut -d"'" -f1) if [ "$AUX" = "$PRESSED" ]; then # Keyboard link already exists... - rm -f ${MDM_DEVICES}/keyboard${XEPHYR_NUMBER} + rm -f $MDM_DEVICES/keyboard${SEAT_NUMBER} CREATED=0 fi fi done done - KEYBOARD="${MDM_DEVICES}/keyboard${XEPHYR_NUMBER}" + KEYBOARD="$MDM_DEVICES/keyboard${SEAT_NUMBER}" } function select_mouse () { - if [ -e "${MDM_DEVICES}/mouse${XEPHYR_NUMBER}" ]; then + if [ -e "${MDM_DEVICES}/mouse${SEAT_NUMBER}" ]; then return fi @@ -169,30 +160,30 @@ function select_mouse () { REMOVE=$(stat -c %N ${MDM_DEVICES}/mouse* 2> /dev/null| cut -d'`' -f3 | cut -d"'" -f1) - for i in $REMOVE; do + for i in ${REMOVE}; do MICE=`sed "s#$i# #g" <<< $MICE` done if [ -z "$MICE" ]; then # No mice. Hopefully someone will connect one. - sleep 10 # Don't use 100% CPU + sleep 1 # Don't use 100% CPU continue fi # Create the lock LOCK_EXISTS=1 while (( LOCK_EXISTS )); do - touch ${MDM_DEVICES}/lock${XEPHYR_NUMBER} + touch ${MDM_DEVICES}/lock${SEAT_NUMBER} LOCK_EXISTS=0 for i in `ls $MDM_DEVICES | grep "\<lock"`; do - if [ "$i" != "lock${XEPHYR_NUMBER}" ]; then + if [ "$i" != "lock${SEAT_NUMBER}" ]; then LOCK_EXISTS=1 fi done if (( LOCK_EXISTS )); then # Yes, we'll call this lots of times... display_message wait - rm -f ${MDM_DEVICES}/lock${XEPHYR_NUMBER} + rm -f ${MDM_DEVICES}/lock${SEAT_NUMBER} sleep 1; fi done @@ -205,39 +196,39 @@ function select_mouse () { if [ -z "$PRESSED" ]; then # If $READ_DEVICES gets killed, don't do unwanted stuff - rm -f ${MDM_DEVICES}/lock${XEPHYR_NUMBER} + rm -f ${MDM_DEVICES}/lock${SEAT_NUMBER} continue fi if [ "$PRESSED" = 'timeout' ]; then # Wait 5 seconds to give other machines the opportunity to enter the # lock display_message wait - rm -f ${MDM_DEVICES}/lock${SCRREN_SEAT} + rm -f ${MDM_DEVICES}/lock${SEAT_NUMBER} sleep 5 continue fi # Ok, someone pressed the key - ln -sf $PRESSED ${MDM_DEVICES}/mouse${XEPHYR_NUMBER} + ln -sf $PRESSED ${MDM_DEVICES}/mouse${SEAT_NUMBER} CREATED=1 # Verify is there is already another link in $MDM_DEVICES/mouse* that # points to the device. If there is, erase the one I created and # continue looping for i in `ls $MDM_DEVICES | grep "\<mouse"`; do - if [ "$i" != "mouse${XEPHYR_NUMBER}" ]; then + if [ "$i" != "mouse${SEAT_NUMBER}" ]; then AUX=$(stat -c %N ${MDM_DEVICES}/$i| cut -d'`' -f3|cut -d"'" -f1) if [ "$AUX" = "$PRESSED" ]; then # Mouse link already exists... - rm -f ${MDM_DEVICES}/mouse${XEPHYR_NUMBER} + rm -f ${MDM_DEVICES}/mouse${SEAT_NUMBER} CREATED=0 fi fi done - rm -f ${MDM_DEVICES}/lock${XEPHYR_NUMBER} + rm -f ${MDM_DEVICES}/lock${SEAT_NUMBER} done - MOUSE="${MDM_DEVICES}/mouse${XEPHYR_NUMBER}" + MOUSE="${MDM_DEVICES}/mouse${SEAT_NUMBER}" } parse_config_file @@ -245,32 +236,29 @@ parse_config_file KEYBOARD= MOUSE= SEAT_WINDOW_ID= -SECOND_ID= -SCREEN_POSITIONS=($(grep -A4 $DISPLAY $XRANDR_INFO | - tail -1 | - cut -d'=' -f2)) -# In case $SCREEN_POSITIONS has only one value, and XEPHYR_NUMBER is odd -# the open_seat_parent_window given parameter would be empty -# (${SCREEN_POSITION[1]}, for example), so, we translate this parameter. -open_seat_parent_window ${SCREEN_POSITIONS[$((XEPHYR_NUMBER%2))]:=0} +open_seat_parent_window while (( 1 )); do + #log --log-file-only "Configuring devices..." echo -e "\n--" echo "Configuring seat:" + echo " selecting keyboard" select_keyboard echo " selecting mouse" select_mouse + echo " starting seat" - display_manager_start_seat $SEAT_WINDOW_ID + display_manager_start_seat display_message reconfigure PRESSED=$($READ_DEVICES 14 $KEYBOARD | grep '^detect' | cut -d'|' -f2) if [ "$PRESSED" = 'esc' ]; then - rm -f $KEYBOARD - rm -f $MOUSE + rm -f $KEYBOARD + rm -f $MOUSE fi + done |