dotfiles/_suckless/_scripts/sb-battery

18 lines
617 B
Plaintext
Raw Normal View History

2021-07-26 15:56:06 +02:00
#!/bin/bash
2021-06-19 15:50:04 +02:00
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
case "$(cat "$battery/status")" in
2022-04-01 00:35:40 +02:00
"Full") status="\ue1a3" ;;
2021-07-26 15:56:06 +02:00
"Discharging") status="\ue1a5" ;;
"Charging") status="\ue63c" ;;
2022-04-01 00:35:40 +02:00
"Not charging") status="\ue1a3" ;;
"Unknown") status="\ue1a6" ;;
2021-06-19 15:50:04 +02:00
esac
capacity=$(cat "$battery/capacity")
# Will make a warn variable if discharging and low
2022-03-07 18:57:13 +01:00
[ "$capacity" -le 20 ] && printf "^c#ffffff^^b#770000^${status} ${capacity}%%^d^" || printf "${status} ${capacity}%%"
2021-06-19 15:50:04 +02:00
done && exit 0