mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 06:23:19 -07:00
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:
parent
e3bc19b5b5
commit
17f530c2a2
1 changed files with 12 additions and 5 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue