Advertisement
PAULDC

Battery Monitor

Jun 8th, 2011
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.43 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. export DISPLAY=:0.0
  4. a=`acpi -b`
  5. len=${#a}
  6. if [ $len -eq 47 ];then
  7.     prcnt=${a:24:2}
  8.     if [ $prcnt -gt 80 ];then
  9.         echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c green -d 59
  10.     elif [ $prcnt -gt 60 ];then
  11.         echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c blue -d 59
  12.     elif [ $prcnt -gt 40 ];then
  13.           echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c yellow -d 59
  14.     elif [ $prcnt -gt 15 ];then
  15.     echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c orange -d 59
  16.     else
  17.     echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c red -d 59
  18.     fi             
  19. else
  20.     prcnt=${a:21:2}
  21.     if [ $prcnt -gt 80 ];then
  22.                 echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c green -d 59
  23.         elif [ $prcnt -gt 60 ];then
  24.                 echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c blue -d 59
  25.         elif [ $prcnt -gt 40 ];then
  26.                   echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c yellow -d 59
  27.         elif [ $prcnt -gt 15 ];then
  28.               echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c orange -d 59
  29.     else
  30.     echo "Battery:$prcnt%"| osd_cat -p top -A center -f lucidasanstypewriter-bold-12 -c red -d 59
  31.         fi
  32. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement