modified: testdata/scripts/op_menu.sh
[pandora-libraries.git] / testdata / scripts / op_menu.sh
1 #!/bin/bash
2 #actions done when the menu button is pressed
3 #only argument is the time the button was pressed in  seconds
4
5 if [ "$1" -ge "3" ]; then #button was pressed 3 sec or longer, show list of apps to kill instead of launcher
6   killist=y
7 fi
8
9 xpid=$(pidof X)
10 if [ $xpid ]; then
11   echo "x is running"
12   if [ $killist ]; then
13     echo "displaying kill list"
14     pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*-\(.*\)(\([0-9]\+\))/\2\n \1/p' | DISPLAY=:0.0 zenity --list --multiple --column "pid" --column "name" --title "kill" --text "which apps should be killed" | sed 's/|/\n/')
15     for PID in $pidlist
16     do
17       kill -9 $PID
18     done
19   else
20   echo "starting appfinder"
21     xfceuser=$(ps ua -C xfce4-session | grep /usr/bin/xfce4-session  | tail -n1 | awk '{print $1}')
22     sudo -u $xfceuser DISPLAY=:0.0 xfce4-appfinder
23   fi
24 else
25   echo "no x, killing all pnd aps so x gets restarted"
26   pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
27   for PID in $pidlist
28   do
29     kill -9 $PID
30   done
31 fi