Subversion Repositories livecd

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

#!/bin/bash
#
# Urs Beyerle, PSI
#

### dialog or xdialog?
DIALOG="dialog"
XDIALOG_HIGH_DIALOG_COMPAT=1
export XDIALOG_HIGH_DIALOG_COMPAT
[ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"

### definitions 
TITLE="PSI Menu"
MENU_TITLE="PSI Menu"

MENU_1="Xterm"
EXEC_1="xterm"

MENU_2="Web Browser (mozilla)"
EXEC_2="mozilla"

MENU_3="NX Client (connect to LLCs)"
EXEC_3="nxclient"

MENU_4="Windows Terminal Server"
EXEC_4="rdesktop $RDESKTOP_OPT -d PSICH -u win_username -a 24 -x lan -r sound:local winterm1"

MENU_5="Windows Terminal Server (full screen)"
EXEC_5="rdesktop $RDESKTOP_OPT -d PSICH -f -u win_username -a 24 -x lan -r sound:local winterm1"

MENU_6="Hardisk Partition Tool (qtparted)"
EXEC_6="qtparted"

MENU_7="Change Keyboard Layout"
EXEC_7="sudo system-config-keyboard"

MENU_8="Configure Display"
EXEC_8="sudo psi-config-display"

MENU_9="Configure Soundcard"
EXEC_9="sudo psi-config-soundcard"

MENU_x="Restart X-Server (will kill all your jobs)"
MENU_down="Reboot/Shutdown"
MENU_quit="Quit"

# tmpdir
TMPDIR=/tmp/psi-menu.$$
TMP=$TMPDIR/dialog
mkdir -p $TMPDIR

### functions
shutdown () 
{
    $DIALOG --title "$TITLE" --radiolist "Reboot or shutdown the PC?" 0 0 3 poweroff "" on reboot "" off 2>$TMP
    ACTION=$(cat $TMP)
    if [ $ACTION ]; then
        $ACTION
        exit 1
    fi
}

# not really restart x, but will kill all processes of localuser
# (including windwos manager and autologin)
restartx ()
{
    ps wwaux | grep "^l_psi" | awk '{ print $2 }' | while read pid; do kill -9 $pid; done    
}

### show menue
while true; do
    $DIALOG --title "$TITLE" \
        --menu "$MENU_TITLE" 0 0 12\
        1 "$MENU_1"\
        2 "$MENU_2"\
        3 "$MENU_3" \
        4 "$MENU_4" \
        5 "$MENU_5" \
        6 "$MENU_6" \
        7 "$MENU_7" \
        8 "$MENU_8" \
        9 "$MENU_9" \
        10 "$MENU_x" \
        11 "$MENU_down" \
        12 "$MENU_quit" \
        2> $TMP

    [ $? -ne 0 ] && break

    CHOICE=$(cat $TMP)

    case "$CHOICE" in
     1)
      (sleep 0.5; $EXEC_1) &
      ;;
     2)
      (sleep 0.5; $EXEC_2) &
      ;;
     3)
      (sleep 0.5; $EXEC_3) &
      ;;
     4)
      (sleep 0.5; $EXEC_4) &
      ;;
     5)
      (sleep 0.5; $EXEC_5) &
      ;;
     6)
      (sleep 0.5; $EXEC_6) &
      ;;
     7)
      (sleep 0.5; $EXEC_7) &
      ;;
     8)
      (sleep 0.5; $EXEC_8) &
      ;;
     9)
      (sleep 0.5; $EXEC_9) &
      ;;
     10)
      restartx
      ;;
     11)
      shutdown || break
      ;;
     12)
      break
      ;;
    esac
done