Modification to always use real root for checking background change
[adesklets.git] / src / adesklets_debug.sh
blob67bdd782aca32bdcdfdc6c2efc1bcf95dc27607f
1 #! /bin/sh
3 # 2004, Sylvain Fourmanoit <syfou@users.sourceforge.net>
5 # Shell script that starts an interactive adesklets session
6 # with the debug (stderr) output in another xterm.
7 #
9 END_MESSAGE='--- End of session ---'
10 FIFO=/tmp/debug_$$.fifo
12 # Termination function
14 the_end() {
15 rm -f $FIFO
16 echo $END_MESSAGE
17 read -p 'Kill debug console (Y/N)? ' -n 1 ANSWER
18 echo
19 echo $ANSWER | grep -i 'y' &>/dev/null && kill $XTERM_PID &>/dev/null
22 # Initial program check
24 export PATH=$PATH:.
25 for PROG in mkfifo xterm adesklets; do
26 test -z `which $PROG 2>/dev/null` && {
27 echo Program $PROG could not be found in path. Aborting. 1>&2
28 exit 1;
30 done
32 # Set up exit trapping
34 trap 'the_end' EXIT
36 # Set up named pipe
38 test ! -p $FIFO && {
39 rm -f $FIFO
40 mkfifo -m 600 $FIFO
43 # Launch programs
45 xterm -e "cat<$FIFO;echo $END_MESSAGE;echo Press a key to kill console;read" &
46 XTERM_PID=$!
47 adesklets : 2>$FIFO