sb-battery: reformat
This commit is contained in:
parent
e763361a3a
commit
e346b923ab
2 changed files with 53 additions and 53 deletions
|
@ -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}"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue