diff options
| author | Luke Smith <luke@lukesmith.xyz> | 2021-02-15 10:53:41 -0500 |
|---|---|---|
| committer | Luke Smith <luke@lukesmith.xyz> | 2021-02-15 10:53:41 -0500 |
| commit | 219ea40fe99d3b64d32532ef826cb6c2ce12feac (patch) | |
| tree | 965dc113908627fe1adb286e284c7aa276d62134 /.local/bin/statusbar | |
| parent | f70f44e4199512b59e26e56c94d815124f4e9f97 (diff) | |
| download | eibhear-219ea40fe99d3b64d32532ef826cb6c2ce12feac.tar.gz eibhear-219ea40fe99d3b64d32532ef826cb6c2ce12feac.tar.zst eibhear-219ea40fe99d3b64d32532ef826cb6c2ce12feac.zip | |
multibattery functionality returned close #899
Diffstat (limited to '.local/bin/statusbar')
| -rwxr-xr-x | .local/bin/statusbar/sb-battery | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index d0272ec..382b31b 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -16,15 +16,12 @@ case $BLOCK_BUTTON in 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -# Check if battery directories are detected -[ ! -e /sys/class/power_supply/BAT?* ] && echo "No battery found" && exit 1 - # Loop through all attached batteries and format the info -for battery in /sys/class/power_supply/BAT?* -do +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 - status=$(cat "$battery/status") - case "$status" in + case "$(cat "$battery/status")" in "Full") status="⚡" ;; "Discharging") status="🔋" ;; "Charging") status="🔌" ;; @@ -35,5 +32,5 @@ do # Will make a warn variable if discharging and low [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" # Prints the info - printf "%s%s%d%%\n" "$status" "$warn" "$capacity"; unset warn -done && return 0 + printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn +done && exit 0 |
