refactored batteries script, tscale_native uses core utils instead of rg and jq

This commit is contained in:
Vlad
2026-01-11 00:00:21 +03:00
parent 63a24620d8
commit 2fe354a1bd
5 changed files with 74 additions and 3 deletions

View File

@ -38,6 +38,8 @@ batteries=$(acpi | rg 'Battery (\d)' -or '$1')
# echo "BATTERIES: $batteries"
text=""
ischarging=0
hasenough=0
for battery in $batteries; do
# echo "BATTERY $battery"
bt=$(acpi -b | grep "Battery $battery")
@ -45,11 +47,18 @@ for battery in $batteries; do
STAT=$(echo "$bt" | rg ": ([\w\s]+)," -or '$1')
ICON=$(geticon "$BAT" "$STAT")
COLOR=$(getcolor "$BAT" "$STAT")
BATTEXT="$ICON $BAT%%"
BATTEXT="$ICON$BAT%%"
text+="<span foreground=\"${COLOR}\">${BATTEXT}</span> "
[ "$STAT" = "Charging" ] && ischarging=1
[ "$BAT" -gt 10 ] hasenough=1
done
printf "${text:0:-1}\n\n"
if [ "$hasenough" -eq 0 ] && [ "$ischarging" -eq 0 ]; then
notify-send "Battery level critical" "Please connect AC"
fi
# bt=$(acpi -b | grep "Battery $1")
# BAT=$(echo "$bt" | rg "(\d?\d?\d)%" -or '$1')
# STAT=$(echo "$bt" | rg ": ([\w\s]+)," -or '$1')