some systems use only lowercase? acpi option added

This commit is contained in:
Luke Smith 2020-05-04 13:06:29 -04:00
parent d0b37d4600
commit 3f20263444
No known key found for this signature in database
GPG key ID: 4C50B54A911F6252

View file

@ -12,12 +12,15 @@ case $BLOCK_BUTTON in
❗: battery very low!" ;; ❗: battery very low!" ;;
esac esac
# acpi alternative
# acpi | sed "s/Battery [0-9]: //;s/[Dd]ischarging, /🔋/;s/[Nn]ot charging, /🛑/;s/[Cc]harging, /🔌/;s/[Uu]nknown, /♻️/;s/[Ff]ull, /⚡/;s/ \(remaining\|until charged\)//"; exit
# Loop through all attached batteries. # Loop through all attached batteries.
for battery in /sys/class/power_supply/BAT? for battery in /sys/class/power_supply/BAT?
do do
# Get its remaining capacity and charge status. # Get its remaining capacity and charge status.
capacity=$(cat "$battery"/capacity) || break capacity=$(cat "$battery"/capacity) || break
status=$(sed "s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/" "$battery"/status) status=$(sed "s/[Dd]ischarging/🔋/;s/[Nn]ot charging/🛑/;s/[Cc]harging/🔌/;s/[Uu]nknown/♻️/;s/[Ff]ull/⚡/" "$battery"/status)
# If it is discharging and 25% or less, we will add a ❗ as a warning. # If it is discharging and 25% or less, we will add a ❗ as a warning.
[ "$capacity" -le 25 ] && [ "$status" = "🔋" ] && warn="❗" [ "$capacity" -le 25 ] && [ "$status" = "🔋" ] && warn="❗"