Subversion Repositories livecd

Rev

Rev 133 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 beyerle@PS 1
#!/bin/bash
2
#
3
# Urs Beyerle, PSI
4
#
5
 
6
### dialog or xdialog?
7
DIALOG="dialog"
8
XDIALOG_HIGH_DIALOG_COMPAT=1
9
export XDIALOG_HIGH_DIALOG_COMPAT
10
[ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
11
 
12
### definitions 
13
TITLE="PSI Menu"
14
MENU_TITLE="PSI Menu"
15
 
16
MENU_1="Xterm"
17
EXEC_1="xterm"
18
 
129 beyerle@PS 19
MENU_2="Web Browser (firefox)"
20
EXEC_2="firefox"
1 beyerle@PS 21
 
22
MENU_3="NX Client (connect to LLCs)"
23
EXEC_3="nxclient"
24
 
25
MENU_4="Windows Terminal Server"
26
EXEC_4="rdesktop $RDESKTOP_OPT -d PSICH -u win_username -a 24 -x lan -r sound:local winterm1"
27
 
28
MENU_5="Windows Terminal Server (full screen)"
29
EXEC_5="rdesktop $RDESKTOP_OPT -d PSICH -f -u win_username -a 24 -x lan -r sound:local winterm1"
30
 
129 beyerle@PS 31
MENU_6="Hardisk Partition Tool (gparted)"
32
EXEC_6="gparted"
1 beyerle@PS 33
 
34
MENU_7="Change Keyboard Layout"
35
EXEC_7="sudo system-config-keyboard"
36
 
37
MENU_8="Configure Display"
38
EXEC_8="sudo psi-config-display"
39
 
40
MENU_9="Configure Soundcard"
133 beyerle@PS 41
EXEC_9="sudo system-config-soundcard"
1 beyerle@PS 42
 
43
MENU_x="Restart X-Server (will kill all your jobs)"
44
MENU_down="Reboot/Shutdown"
45
MENU_quit="Quit"
46
 
47
# tmpdir
48
TMPDIR=/tmp/psi-menu.$$
49
TMP=$TMPDIR/dialog
50
mkdir -p $TMPDIR
51
 
52
### functions
53
shutdown () 
54
{
55
    $DIALOG --title "$TITLE" --radiolist "Reboot or shutdown the PC?" 0 0 3 poweroff "" on reboot "" off 2>$TMP
56
    ACTION=$(cat $TMP)
57
    if [ $ACTION ]; then
58
	$ACTION
59
	exit 1
60
    fi
61
}
62
 
63
# not really restart x, but will kill all processes of localuser
64
# (including windwos manager and autologin)
65
restartx ()
66
{
134 beyerle@PS 67
    ( sleep 2; rm -f /tmp/.X0-lock; sudo psi-restart-xserver; rm -f /tmp/.X0-lock ) &
1 beyerle@PS 68
    ps wwaux | grep "^l_psi" | awk '{ print $2 }' | while read pid; do kill -9 $pid; done    
69
}
70
 
71
### show menue
72
while true; do
73
    $DIALOG --title "$TITLE" \
74
	--menu "$MENU_TITLE" 0 0 12\
75
	1 "$MENU_1"\
76
	2 "$MENU_2"\
77
	3 "$MENU_3" \
78
	4 "$MENU_4" \
79
	5 "$MENU_5" \
80
	6 "$MENU_6" \
81
	7 "$MENU_7" \
82
	8 "$MENU_8" \
83
	9 "$MENU_9" \
84
	10 "$MENU_x" \
85
	11 "$MENU_down" \
86
	12 "$MENU_quit" \
87
	2> $TMP
88
 
89
    [ $? -ne 0 ] && break
90
 
91
    CHOICE=$(cat $TMP)
92
 
93
    case "$CHOICE" in
94
     1)
95
      (sleep 0.5; $EXEC_1) &
96
      ;;
97
     2)
98
      (sleep 0.5; $EXEC_2) &
99
      ;;
100
     3)
101
      (sleep 0.5; $EXEC_3) &
102
      ;;
103
     4)
104
      (sleep 0.5; $EXEC_4) &
105
      ;;
106
     5)
107
      (sleep 0.5; $EXEC_5) &
108
      ;;
109
     6)
110
      (sleep 0.5; $EXEC_6) &
111
      ;;
112
     7)
113
      (sleep 0.5; $EXEC_7) &
114
      ;;
115
     8)
116
      (sleep 0.5; $EXEC_8) &
117
      ;;
118
     9)
119
      (sleep 0.5; $EXEC_9) &
120
      ;;
121
     10)
122
      restartx
123
      ;;
124
     11)
125
      shutdown || break
126
      ;;
127
     12)
128
      break
129
      ;;
130
    esac
131
done