45 lines
1.2 KiB
Bash
Executable file
45 lines
1.2 KiB
Bash
Executable file
#!/bin/sh
|
|
. libsb
|
|
|
|
[ -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>"
|
|
done
|