Fixed batteries script

This commit is contained in:
Nefrace 2025-05-31 17:41:56 +03:00
parent d66332ed2a
commit 9c8b87bcc6
1 changed files with 4 additions and 3 deletions

View File

@ -37,6 +37,7 @@ getcolor() {
batteries=$(acpi | rg 'Battery (\d)' -or '$1')
# echo "BATTERIES: $batteries"
text=""
for battery in $batteries; do
# echo "BATTERY $battery"
bt=$(acpi -b | grep "Battery $battery")
@ -44,10 +45,10 @@ for battery in $batteries; do
STAT=$(echo "$bt" | rg ": ([\w\s]+)," -or '$1')
ICON=$(geticon "$BAT" "$STAT")
COLOR=$(getcolor "$BAT" "$STAT")
text="$ICON $BAT"
printf "<span foreground=\"${COLOR}\">${text}</span>"
BATTEXT="$ICON $BAT%%"
text+="<span foreground=\"${COLOR}\">${BATTEXT}</span> "
done
printf "\n\n"
printf "${text:0:-1}\n\n"
# bt=$(acpi -b | grep "Battery $1")
# BAT=$(echo "$bt" | rg "(\d?\d?\d)%" -or '$1')