2022-07-31 23:33:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
icon='\uf241 '
|
|
|
|
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
|
|
|
|
"Full") status="\uf102" ;;
|
|
|
|
"Discharging") status="\uf078" ;;
|
|
|
|
"Charging") status="\uf077" ;;
|
|
|
|
"Not charging") status="\uf444" ;;
|
|
|
|
"Unknown") status="\uf128" ;;
|
|
|
|
esac
|
|
|
|
capacity=$(cat "$battery/capacity")
|
|
|
|
# Will make a warn variable if discharging and low
|
2022-08-31 18:14:21 +02:00
|
|
|
[ "$capacity" -le 20 ] && printf "<span foreground='#ffffff' background='#770000'>$icon ${status} ${capacity}%%</span>" || printf "$icon ${status} ${capacity}%%"
|
2022-07-31 23:33:25 +02:00
|
|
|
done && exit 0
|