From 25576ab467aae1ca5e62405bfca934a4624b7b54 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sun, 28 Jun 2020 00:02:00 +0200 Subject: [PATCH] Prevent error when having no battery --- .local/bin/statusbar/battery | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.local/bin/statusbar/battery b/.local/bin/statusbar/battery index a6fb62d1..b60cb4b6 100755 --- a/.local/bin/statusbar/battery +++ b/.local/bin/statusbar/battery @@ -20,7 +20,8 @@ esac for battery in /sys/class/power_supply/BAT? do # Get its remaining capacity and charge status. - capacity=$(cat "$battery"/capacity) || break + [ -f "$battery"/capacity ] || break + capacity=$(cat "$battery"/capacity) 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.