Apply the background to an ASCII art battery with a sign in it:

* - for discharging
  * + for charging
  * = for full

Change the background color of the ASCII art battery only to reflect the state:
  * green: OK
  * orange: warn
  * red: low
This commit is contained in:
Raphaël Pinson 2009-04-01 18:56:50 +02:00
commit 17f530c2a2

View file

@ -54,13 +54,14 @@ for bat in $BATS; do
rem=$(search "$statefile" "remaining capacity: *\(.*\) m[AW]h") rem=$(search "$statefile" "remaining capacity: *\(.*\) m[AW]h")
if [ "$rem" -lt "$low" ]; then if [ "$rem" -lt "$low" ]; then
alert="\005{=b .r}" color="\005{= r.}"
elif [ "$rem" -lt "$warn" ]; then elif [ "$rem" -lt "$warn" ]; then
alert="\005{= .y}" color="\005{= y.}"
else else
alert="" color="\005{= g.}"
fi fi
percent=$(echo "100*$rem/$full" | bc) percent=$(echo "100*$rem/$full" | bc)
state=$(search "$statefile" "charging state: *\(.*\)") state=$(search "$statefile" "charging state: *\(.*\)")
@ -68,12 +69,18 @@ for bat in $BATS; do
charging) charging)
sign="+" sign="+"
;; ;;
discharging)
sign="-"
;;
charged)
sign="="
;;
*) *)
sign="" sign="$state"
;; ;;
esac esac
echo "${alert}${percent}%${sign}" echo "${color}|${sign}|\005{-}${percent}%"
done done