Advertisement
Guest User

J Bobby Lopez

a guest
Feb 5th, 2010
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.59 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Script to load Dzen with output from 'dzen-mounts.pl' script
  4. # Written by J. Bobby Lopez <jbl@jbldata.com> - 27 Jan 2010
  5. #
  6. # This script utilizes the Dzen notification system
  7. # Information on Dzen can be found at http://dzen.geekmode.org/
  8.  
  9. #DZPATH=`echo -ne "$0" | sed -e 's/\/dzen.*$//'`;
  10. #echo $DZPATH;
  11.  
  12. function mountlines
  13. {
  14.         LINES=`perl /home/jbl/bin/myscripts/dzen-mounts.pl  | wc -l`;
  15.         echo "$LINES"
  16. }
  17.  
  18. function freshmounts
  19. {
  20.         OUTPUT=`perl /home/jbl/bin/myscripts/dzen-mounts.pl`;
  21.         echo "$OUTPUT"
  22. }
  23.  
  24. function rundzen
  25. {
  26.         OUTPUT=`freshmounts`;
  27.         MOUNTLINES=`mountlines`;
  28.         echo "$OUTPUT" | dzen2 -p -l "$MOUNTLINES" -u -x 500 -y 0 -w 600 -h 12 -tw 120 -ta l &
  29.         PID=`pgrep -f "dzen2 -p -l $MOUNTLINES -u -x 500 -y 0 -w 600 -h 12 -tw 120 -ta l"`;
  30.         echo "$PID"
  31. }
  32.  
  33. function killdzen
  34. {
  35.         PID="$1"
  36.         if [ ! "$PID" ]; then
  37.             MOUNTLINES=`mountlines`;
  38.             PID=`pgrep -f "dzen2 -p -l $MOUNTLINES -u -x 500 -y 0 -w 600 -h 12 -tw 120 -ta l"`;
  39.         fi
  40.  
  41.         if [ "$PID" ]; then
  42.             #echo "Killing $PID..";  # DEBUG STATEMENT
  43.             kill "$PID";
  44.         fi;
  45. }
  46.  
  47. function checkchanges
  48. {
  49.     while true; do
  50.         NEW=`freshmounts`;
  51.         #echo "$NEW - new";  # DEBUG STATEMENT
  52.         if [ "$OLD" != "$NEW" ]; then
  53.             killdzen "$PID";
  54.             rundzen;
  55.             #echo "$PID started";  # DEBUG STATEMENT
  56.             OLD="$NEW";
  57.             #echo "$OLD - old updated"  # DEBUG STATEMENT
  58.         fi
  59.         sleep 1;
  60.     done
  61. }
  62.  
  63. checkchanges
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement