2022-09-21 21:46:27 +02:00
|
|
|
#!/bin/sh
|
2023-05-24 18:33:43 +02:00
|
|
|
red="\033[31m"
|
|
|
|
orange="\033[33m"
|
|
|
|
cyan="\033[36m"
|
|
|
|
green="\033[32m"
|
|
|
|
white="\033[37m"
|
|
|
|
reset="\033[0m"
|
2022-09-21 21:46:27 +02:00
|
|
|
for battery in /sys/class/power_supply/BAT?*; do
|
2023-02-07 17:19:53 +01:00
|
|
|
pidof -x sbd-battery >/dev/null 2>&1 || sbd-battery "$battery" >/dev/null 2>&1 &
|
2022-09-21 21:46:27 +02:00
|
|
|
[ -n "${capacity+x}" ] && printf " "
|
|
|
|
capacity="$(cat "$battery/capacity" 2>&1)"
|
|
|
|
case "$(cat "$battery/status" 2>&1)" in
|
2023-02-07 17:19:53 +01:00
|
|
|
"Full")
|
|
|
|
icon=""
|
|
|
|
color="$green"
|
|
|
|
;;
|
|
|
|
"Charging")
|
|
|
|
icon=""
|
|
|
|
color="$cyan"
|
|
|
|
;;
|
|
|
|
"Not charging")
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
;;
|
|
|
|
"Unknown")
|
|
|
|
icon=""
|
|
|
|
color="$orange"
|
|
|
|
;;
|
|
|
|
"Discharging")
|
|
|
|
if [ "$capacity" -le 10 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$red"
|
|
|
|
elif [ "$capacity" -le 20 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$red"
|
|
|
|
elif [ "$capacity" -le 30 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
elif [ "$capacity" -le 40 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
elif [ "$capacity" -le 50 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
elif [ "$capacity" -le 60 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
elif [ "$capacity" -le 70 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
elif [ "$capacity" -le 80 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
elif [ "$capacity" -le 90 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
elif [ "$capacity" -le 95 ]; then
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
else
|
|
|
|
icon=""
|
|
|
|
color="$white"
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
*) exit 1 ;;
|
2022-09-21 21:46:27 +02:00
|
|
|
esac
|
2023-05-24 18:33:43 +02:00
|
|
|
printf "%b" "$color$icon$reset $capacity"
|
2022-09-21 21:46:27 +02:00
|
|
|
done && printf "\\n"
|