summaryrefslogtreecommitdiffstats
path: root/.local/bin/statusbar
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/statusbar')
-rwxr-xr-x.local/bin/statusbar/sb-battery7
1 files changed, 4 insertions, 3 deletions
diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery
index 382b31b..93cbe08 100755
--- a/.local/bin/statusbar/sb-battery
+++ b/.local/bin/statusbar/sb-battery
@@ -21,16 +21,17 @@ 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")" in
+ case "$(cat "$battery/status" 2>&1)" in
"Full") status="⚡" ;;
"Discharging") status="🔋" ;;
"Charging") status="🔌" ;;
"Not charging") status="🛑" ;;
"Unknown") status="♻️" ;;
+ *) exit 1 ;;
esac
- capacity=$(cat "$battery/capacity")
+ 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 && exit 0
+done && printf "\\n"