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