From 2f7e80161ce61def99113421611dfb960b8f94df Mon Sep 17 00:00:00 2001 From: saloniamatteo Date: Wed, 20 Nov 2024 15:03:41 +0100 Subject: [PATCH] Update battery indicator --- scripts/.local/bin/battery | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/.local/bin/battery b/scripts/.local/bin/battery index 293d9be..9c2f146 100755 --- a/scripts/.local/bin/battery +++ b/scripts/.local/bin/battery @@ -20,18 +20,22 @@ esac for battery in /sys/class/power_supply/BAT?*; do # If non-first battery, print a space separator. [ -n "${capacity+x}" ] && printf " " + # Sets up the status and capacity case "$(cat "$battery/status" 2>&1)" in - "Full") status="⚡" ;; + "Full") status="⚡ " ;; "Discharging") status="🔋 " ;; - "Charging") status="🔌" ;; + "Charging") status="🔌 " ;; "Not charging") status="🛑 " ;; - "Unknown") status="♻️" ;; + "Unknown") status="♻️ " ;; *) exit 1 ;; esac + capacity="$(cat "$battery/capacity" 2>&1)" + # Will make a warn variable if discharging and low [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" + # Prints the info printf "%s%s%d%%" "$status" "$warn" " $capacity"; unset warn done && printf "\\n"