From 17f530c2a2521f5847fb05a653151a4aa1f27afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 1 Apr 2009 18:56:50 +0200 Subject: [PATCH] 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 --- bin/battery_state | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/battery_state b/bin/battery_state index 6974359f..2e3e2172 100755 --- a/bin/battery_state +++ b/bin/battery_state @@ -54,13 +54,14 @@ for bat in $BATS; do rem=$(search "$statefile" "remaining capacity: *\(.*\) m[AW]h") if [ "$rem" -lt "$low" ]; then - alert="\005{=b .r}" + color="\005{= r.}" elif [ "$rem" -lt "$warn" ]; then - alert="\005{= .y}" + color="\005{= y.}" else - alert="" + color="\005{= g.}" fi + percent=$(echo "100*$rem/$full" | bc) state=$(search "$statefile" "charging state: *\(.*\)") @@ -68,12 +69,18 @@ for bat in $BATS; do charging) sign="+" ;; + discharging) + sign="-" + ;; + charged) + sign="=" + ;; *) - sign="" + sign="$state" ;; esac - echo "${alert}${percent}%${sign}" + echo "${color}|${sign}|\005{-}${percent}%" done