op_menu: try to be a bit more useful
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_menu.sh
index 8ec9fd8..b7c2dba 100644 (file)
@@ -2,8 +2,30 @@
 #actions done when the menu button is pressed
 #only argument is the time the button was pressed in  seconds
 
+if [ -x /usr/pandora/scripts/op_menu_custom.sh ]; then
+  exec /usr/pandora/scripts/op_menu_custom.sh "$@"
+fi
+
+do_kill()
+{
+  for PID in "$@"; do
+    kill $PID
+  done
+  sleep 1
+  for PID in "$@"; do
+    kill -9 $PID
+  done
+}
+
 if [ "$1" -ge "2" ]; then #button was pressed 3 sec or longer, show list of apps to kill instead of launcher
   killist=y
+
+  # if something uses fb1 or SGX, try killing them instead
+  fb_users=`lsof -t /dev/fb1 /dev/pvrsrvkm`
+  if [ -n "$fb_users" ]; then
+    do_kill $fb_users
+  fi
+  exit 1
 fi
 
 xpid=$(pidof xfce4-session)
@@ -14,10 +36,7 @@ if [ $xpid ]; then
   if [ $killist ]; then
     echo "displaying kill list"
     pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*-\(.*\)(\([0-9]\+\))/\2\n \1/p' | su -c 'DISPLAY=:0.0 zenity --list --multiple --column "pid" --column "name" --title "kill" --text "which apps should be killed"' - $xfceuser | sed 's/|/\n/')
-    for PID in $pidlist
-    do
-      kill -9 $PID
-    done
+    do_kill $pidlist
   else
     # echo "starting appfinder"
     # invoke the appfinder; nice app, but it takes a few seconds to come up
@@ -28,8 +47,5 @@ if [ $xpid ]; then
 else
   echo "no x, killing all pnd aps so x or DE gets restarted"
   pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
-  for PID in $pidlist
-  do
-    kill -9 $PID
-  done
+  do_kill $pidlist
 fi