panel: add battery lemon
This commit is contained in:
parent
145fbccbfb
commit
aec4c9c593
22
os/arch/.config/panel/lemons/battery
Executable file
22
os/arch/.config/panel/lemons/battery
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env dash
|
||||||
|
|
||||||
|
# No guarantee that it will be called BAT0, but it suits my purposes.
|
||||||
|
if ! command -v acpi >/dev/null
|
||||||
|
then
|
||||||
|
>&2 echo "acpi is not installed, battery segment disabled"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
if [ ! -d "/sys/class/power_supply/BAT0" ]
|
||||||
|
then
|
||||||
|
>&2 echo "No battery! This must be a PC"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
BAT=$(acpi --battery)
|
||||||
|
PERC=$(echo $BAT | cut -d, -f2)
|
||||||
|
echo -n "B${PERC#?}:"
|
||||||
|
echo "$BAT" | grep charging >/dev/null && echo "1" || echo "0"
|
||||||
|
sleep 15
|
||||||
|
done
|
|
@ -60,6 +60,22 @@ parse() {
|
||||||
data="${line#?}"
|
data="${line#?}"
|
||||||
case $line in
|
case $line in
|
||||||
# Minimal icons
|
# Minimal icons
|
||||||
|
B*) perc="${data%\%:*}"
|
||||||
|
state="${data#*:}"
|
||||||
|
case "${perc}" in
|
||||||
|
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
|
||||||
|
[ "$state" = "1" ] && battery="${icon}${ICON_BATAC}" || battery="${icon} "
|
||||||
|
;;
|
||||||
U*) updates=" %{F${COLOR_DIM}}$ICON_UPD%{F-}"
|
U*) updates=" %{F${COLOR_DIM}}$ICON_UPD%{F-}"
|
||||||
if [ "$data" -gt 0 ]; then
|
if [ "$data" -gt 0 ]; then
|
||||||
updates=" %{F${COLOR_2}}$ICON_UPD$data%{F-}"
|
updates=" %{F${COLOR_2}}$ICON_UPD$data%{F-}"
|
||||||
|
@ -187,7 +203,7 @@ parse() {
|
||||||
echo -e \
|
echo -e \
|
||||||
"%{l}${wm}${song}" \
|
"%{l}${wm}${song}" \
|
||||||
"%{c}${xtitle}" \
|
"%{c}${xtitle}" \
|
||||||
"%{r}${mail}${updates}${vol}${wifi}${datetime} "
|
"%{r}${battery}${mail}${updates}${vol}${wifi}${datetime} "
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,3 +68,15 @@ ICON_SPEAKER=""
|
||||||
# misc
|
# misc
|
||||||
ICON_MAIL=""
|
ICON_MAIL=""
|
||||||
ICON_UPD=""
|
ICON_UPD=""
|
||||||
|
# battery
|
||||||
|
ICON_BAT0=""
|
||||||
|
ICON_BAT1=""
|
||||||
|
ICON_BAT2=""
|
||||||
|
ICON_BAT3=""
|
||||||
|
ICON_BAT4=""
|
||||||
|
ICON_BAT5=""
|
||||||
|
ICON_BAT6=""
|
||||||
|
ICON_BAT7=""
|
||||||
|
ICON_BAT8=""
|
||||||
|
ICON_BAT9=""
|
||||||
|
ICON_BATAC=""
|
||||||
|
|
Loading…
Reference in a new issue