From 3f20263444539b59a54fc43f027e2c39d0b5e69a Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 4 May 2020 13:06:29 -0400 Subject: [PATCH] some systems use only lowercase? acpi option added --- .local/bin/statusbar/battery | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.local/bin/statusbar/battery b/.local/bin/statusbar/battery index 97868bb..d348279 100755 --- a/.local/bin/statusbar/battery +++ b/.local/bin/statusbar/battery @@ -12,12 +12,15 @@ case $BLOCK_BUTTON in ❗: battery very low!" ;; 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. for battery in /sys/class/power_supply/BAT? do # Get its remaining capacity and charge status. 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. [ "$capacity" -le 25 ] && [ "$status" = "🔋" ] && warn="❗"