From f34a55dd9ad8c20e367773a94c1abac336345c37 Mon Sep 17 00:00:00 2001 From: Hekuran Date: Thu, 24 Feb 2022 18:08:02 +0100 Subject: [PATCH] Much cleaner without inside ifs --- .local/bin/statusbar/sb-battery | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index e53e2677..0845e0c5 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -31,12 +31,9 @@ for battery in /sys/class/power_supply/BAT?*; do *) exit 1 ;; esac capacity="$(cat "$battery/capacity" 2>&1)" - if [ "$status" = "🔋" ]; then - # Changes the icon if lower than 50% and discharging - [ "$capacity" -le 50 ] && status="đŸĒĢ" - # Will make a warn variable if discharging and very low - [ "$capacity" -le 25 ] && warn="❗" - fi + test $stat = '🔋' && \ + test $capa -le 50 && stat='đŸĒĢ' && \ + test $capa -le 25 && warn='❗' # Prints the info printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn done && printf "\\n"