From 3c6cf7ee3eb1cd768072b21c569a69428bf3ce4c Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Sun, 8 Jul 2012 04:00:15 +0200 Subject: inital commit --- bin/bat.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 bin/bat.sh (limited to 'bin/bat.sh') diff --git a/bin/bat.sh b/bin/bat.sh new file mode 100644 index 0000000..e546209 --- /dev/null +++ b/bin/bat.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +STATEFILE='/proc/acpi/battery/BAT0/state' # battery's state file +INFOFILE='/proc/acpi/battery/BAT0/info' # battery's info file + +while true +do + BAT_FULL=`cat $INFOFILE | grep "last full" |cut -d " " -f 9`; + STATUS=`cat $STATEFILE | grep charging |cut -d " " -f 12`; + RCAP=`cat $STATEFILE | grep remaining |cut -d " " -f 8`; + + RPERCT=`expr $RCAP \* 100`; + RPERC=`expr $RPERCT / $BAT_FULL`; + + echo -n '^p(10)' + + if [ $RPERC -ge 100 ] + then + RPERC=100 + fi + + # draw the bar and pipe everything into dzen + COLOR="#999" + IMAGE="power-ac" + + if [ "$STATUS" == "discharging" ] + then + if [ $RPERC -le 20 ] + then + COLOR="#f00" + IMAGE="power-bat-empty" + else + IMAGE="power-bat-full" + fi + fi + + echo $RPERC | gdbar -h 6 -w 50 -fg "${COLOR}" -bg '#444' -l "^i(/home/alex/.dzen2/icons/${IMAGE}.xbm) " -nonl + echo " ${RPERC}%" + sleep 5; +done -- cgit v1.2.3