Subversion Repositories livecd

Rev

Details | 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
{
67
    ps wwaux | grep "^l_psi" | awk '{ print $2 }' | while read pid; do kill -9 $pid; done    
68
}
69
 
70
### show menue
71
while true; do
72
    $DIALOG --title "$TITLE" \
73
	--menu "$MENU_TITLE" 0 0 12\
74
	1 "$MENU_1"\
75
	2 "$MENU_2"\
76
	3 "$MENU_3" \
77
	4 "$MENU_4" \
78
	5 "$MENU_5" \
79
	6 "$MENU_6" \
80
	7 "$MENU_7" \
81
	8 "$MENU_8" \
82
	9 "$MENU_9" \
83
	10 "$MENU_x" \
84
	11 "$MENU_down" \
85
	12 "$MENU_quit" \
86
	2> $TMP
87
 
88
    [ $? -ne 0 ] && break
89
 
90
    CHOICE=$(cat $TMP)
91
 
92
    case "$CHOICE" in
93
     1)
94
      (sleep 0.5; $EXEC_1) &
95
      ;;
96
     2)
97
      (sleep 0.5; $EXEC_2) &
98
      ;;
99
     3)
100
      (sleep 0.5; $EXEC_3) &
101
      ;;
102
     4)
103
      (sleep 0.5; $EXEC_4) &
104
      ;;
105
     5)
106
      (sleep 0.5; $EXEC_5) &
107
      ;;
108
     6)
109
      (sleep 0.5; $EXEC_6) &
110
      ;;
111
     7)
112
      (sleep 0.5; $EXEC_7) &
113
      ;;
114
     8)
115
      (sleep 0.5; $EXEC_8) &
116
      ;;
117
     9)
118
      (sleep 0.5; $EXEC_9) &
119
      ;;
120
     10)
121
      restartx
122
      ;;
123
     11)
124
      shutdown || break
125
      ;;
126
     12)
127
      break
128
      ;;
129
    esac
130
done