Advertisement
Guest User

op_menu.sh

a guest
Apr 6th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.36 KB | None | 0 0
  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 "2" ]; 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 xfce4-session)
  10. if [ $xpid ]; then
  11.   echo "xfce4 is running"
  12.   # note: max username length ps can output is 19, otherwise it prints uid
  13.   xfceuser=$(ps -o user:20= -C xfce4-session | tail -n1 | awk '{print $1}')
  14.   if [ $killist ]; then
  15.     echo "displaying kill list"
  16.     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/')
  17.     for PID in $pidlist
  18.     do
  19.       kill -9 $PID
  20.     done
  21.   else
  22.     # echo "starting appfinder"
  23.     # invoke the appfinder; nice app, but it takes a few seconds to come up
  24.     #su -c 'DISPLAY=:0.0 xfce4-appfinder' - $xfceuser
  25.     # invoke the bottom-left popup menu, for launching new apps, instead.
  26.     su -c 'DISPLAY=:0.0 /usr/pandora/scripts/op_xfcemenu.sh' - $xfceuser
  27.   fi
  28. else
  29.   echo "no x, killing all pnd aps so x or DE gets restarted"
  30.   pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
  31.   for PID in $pidlist
  32.   do
  33.     kill -9 $PID
  34.   done
  35. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement