From e346b923ab12ae0c3772eeb6fb529a432e31c84c Mon Sep 17 00:00:00 2001 From: Luca Bilke <luca@bil.ke> Date: Wed, 9 Oct 2024 15:22:18 +0200 Subject: [PATCH] sb-battery: reformat --- common/.local/libexec/statusbar/libsb | 28 ++++---- common/.local/libexec/statusbar/sb-battery | 78 +++++++++++----------- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/common/.local/libexec/statusbar/libsb b/common/.local/libexec/statusbar/libsb index 9d8a9269..ad265d2c 100755 --- a/common/.local/libexec/statusbar/libsb +++ b/common/.local/libexec/statusbar/libsb @@ -23,18 +23,18 @@ export bggray="background='#414868$bgalpha'" export bgwhite="background='#C0CAF5$bgalpha'" meter_bar() { - # shellcheck disable=SC2194 - case $1 in - 9[0-9] | 100) color="$fgred" bar="▉" ;; - 8[0-9]) color="$fgred" bar="█" ;; - 7[0-9]) color="$fgorange" bar="▇" ;; - 6[0-9]) color="$fgorange" bar="▆" ;; - 5[0-9]) color="$fggreen" bar="▅" ;; - 4[0-9]) color="$fggreen" bar="▄" ;; - 3[0-9]) color="$fggreen" bar="▂" ;; - 2[0-9]) color="$fggreen" bar="▂" ;; - 1[0-9]) color="$fggreen" bar="▁" ;; - 0[0-9] | [0-9]) color="$fggreen" bar=" " ;; - esac - printf "%s:%s" "${color}" "${bar}" + # shellcheck disable=SC2194 + case $1 in + 9[0-9] | 100) color="$fgred" bar="▉" ;; + 8[0-9]) color="$fgred" bar="█" ;; + 7[0-9]) color="$fgorange" bar="▇" ;; + 6[0-9]) color="$fgorange" bar="▆" ;; + 5[0-9]) color="$fggreen" bar="▅" ;; + 4[0-9]) color="$fggreen" bar="▄" ;; + 3[0-9]) color="$fggreen" bar="▂" ;; + 2[0-9]) color="$fggreen" bar="▂" ;; + 1[0-9]) color="$fggreen" bar="▁" ;; + 0[0-9] | [0-9]) color="$fggreen" bar=" " ;; + esac + printf "%s:%s" "${color}" "${bar}" } diff --git a/common/.local/libexec/statusbar/sb-battery b/common/.local/libexec/statusbar/sb-battery index c3923c90..e49791a9 100755 --- a/common/.local/libexec/statusbar/sb-battery +++ b/common/.local/libexec/statusbar/sb-battery @@ -3,43 +3,43 @@ [ -z "$(ls /sys/class/power_supply)" ] && exit 0 -for battery in /sys/class/power_supply/BAT?*; do - pidof -x sbd-battery >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-battery" "$battery" >/dev/null 2>&1 & - [ -n "${capacity+x}" ] && printf " " - capacity="$(cat "$battery/capacity" 2>&1)" - case "$(cat "$battery/status" 2>&1)" in - "Full") - icon="" - color="$fgcyan" - ;; - "Not charging") - icon="" - color="$fggreen" - ;; - "Unknown") - icon="" - color="$fgorange" - ;; - "Charging") - icon="" - color="$fgcyan" - ;; - "Discharging") - case $capacity in - [0-5]) icon="" color="$fgred" ;; - [6-9] | 10) icon="" color="$fgred" ;; - 1[1-9] | 20) icon="" color="$fgred" ;; - 2[1-9] | 30) icon="" color="$fgwhite" ;; - 3[1-9] | 40) icon="" color="$fgwhite" ;; - 4[1-9] | 50) icon="" color="$fgwhite" ;; - 5[1-9] | 60) icon="" color="$fgwhite" ;; - 6[1-9] | 70) icon="" color="$fgwhite" ;; - 7[1-9] | 80) icon="" color="$fgwhite" ;; - 8[1-9] | 90) icon="" color="$fgwhite" ;; - 9[1-9] | 100) icon="" color="$fgwhite" ;; - esac - ;; - *) exit 1 ;; - esac - printf "%b" "<span $color>$icon</span>" +for battery in /sys/class/power_supply/BAT*; do + pidof -x sbd-battery >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-battery" "$battery" >/dev/null 2>&1 & + [ -n "${capacity+x}" ] && printf " " + capacity="$(cat "$battery/capacity" 2>&1)" + case "$(cat "$battery/status" 2>&1)" in + "Full") + icon="" + color="$fgcyan" + ;; + "Not charging") + icon="" + color="$fggreen" + ;; + "Unknown") + icon="" + color="$fgorange" + ;; + "Charging") + icon="" + color="$fgcyan" + ;; + "Discharging") + case $capacity in + [0-5]) icon="" color="$fgred" ;; + [6-9] | 10) icon="" color="$fgred" ;; + 1[1-9] | 20) icon="" color="$fgred" ;; + 2[1-9] | 30) icon="" color="$fgwhite" ;; + 3[1-9] | 40) icon="" color="$fgwhite" ;; + 4[1-9] | 50) icon="" color="$fgwhite" ;; + 5[1-9] | 60) icon="" color="$fgwhite" ;; + 6[1-9] | 70) icon="" color="$fgwhite" ;; + 7[1-9] | 80) icon="" color="$fgwhite" ;; + 8[1-9] | 90) icon="" color="$fgwhite" ;; + 9[1-9] | 100) icon="" color="$fgwhite" ;; + esac + ;; + *) exit 1 ;; + esac + printf "%b" "<span $color>$icon</span>" done