helm/os/arch/.config/panel/lemons/battery

38 lines
1,023 B
Plaintext
Raw Normal View History

2016-11-05 08:27:49 -07:00
#!/usr/bin/env dash
2016-11-06 16:40:02 -08:00
. $(dirname $0)/../panel-config
2016-11-05 08:27:49 -07:00
# No guarantee that it will be called BAT0, but it suits my purposes.
if ! command -v acpi >/dev/null; then
2016-11-05 08:27:49 -07:00
>&2 echo "acpi is not installed, battery segment disabled"
exit
fi
if [ ! -d /sys/class/power_supply/BAT0 ]; then
2016-11-05 08:27:49 -07:00
>&2 echo "No battery! This must be a PC"
exit
fi
while :; do
data=$(acpi --battery)
perc=${${${data#*,}%,*}:1:-1}
2016-11-06 16:40:02 -08:00
case $perc in
2016-11-06 16:40:02 -08:00
100|9[0-9]) icon="${ICON_BAT9}" ;;
8[0-9]) icon="${ICON_BAT8}" ;;
7[0-9]) icon="${ICON_BAT7}" ;;
6[0-9]) icon="${ICON_BAT6}" ;;
5[0-9]) icon="${ICON_BAT5}" ;;
4[0-9]) icon="${ICON_BAT4}" ;;
3[0-9]) icon="%{F$COLOR_3}${ICON_BAT3}%{F-}" ;;
2[0-9]) icon="%{F$COLOR_3}${ICON_BAT2}%{F-}" ;;
1[0-9]) icon="%{F$COLOR_1}${ICON_BAT1}%{F-}" ;;
*) icon="%{F$COLOR_1}${ICON_BAT0}%{F-}" ;;
esac
echo -n "${icon}"
[ "${data/ charging/}" == "$data" ] && echo "${ICON_BATAC}"
2016-11-06 16:40:02 -08:00
2016-11-05 08:27:49 -07:00
sleep 15
done
# vim:set ft=sh: