no percentage, 25% intervals via font-awesome

This commit is contained in:
Alexander Bocken 2023-10-13 13:08:07 +02:00
parent d24065a7a5
commit 8173732805
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

View File

@ -27,13 +27,21 @@ do
printf '\n' &&
continue
status=$(sed "s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown/🔋/;s/Full/⚡/" "$battery"/status)
# If it is discharging and 25% or less, we will add a ❗ as a warning.
[ "$capacity" -le 25 ] &&
[ "$status" = "🔋" ] &&
warn="❗"
printf "%s%s%s%%\n" "$status" "$warn" "$capacity"
unset warn
status=$(sed "s/Discharging//;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown/🔋/;s/Full/⚡/" "$battery"/status)
# Center picture around the actual capacity.
# Displayable capacities: 0, 1/4, 1/2, 3/4, 1 -> intervall of length 25% centered around displaycategory
# -> +- 12.5% for every level
if [ "$status" = "" ]; then
[ "$capacity" -le 13 ] &&
status=""
[ "$capacity" -le 37 ] &&
status=""
[ "$capacity" -le 63 ] &&
status=""
[ "$capacity" -le 87 ] &&
status=""
fi
printf "%s\n" "$status"
else
echo "Error. Capacity:$capacity" > /dev/stderr #if battery fails during reading, quit
fi