From 8173732805e6c17aadae39c9b838b7e50b08665d Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Fri, 13 Oct 2023 13:08:07 +0200 Subject: [PATCH] no percentage, 25% intervals via font-awesome --- .local/bin/statusbar/sb-battery | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index 2ca8219..fe7b5cf 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -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