herbstluftwm: panel: add battery information

This commit is contained in:
Thomas Preisner 2016-12-09 02:19:23 +01:00
parent dc18815467
commit 36a56026a1

View file

@ -83,6 +83,25 @@ function cpu() {
echo -n $(icon temp yellow) ${cpu} echo -n $(icon temp yellow) ${cpu}
} }
# BATTERY
function battery() {
if [ "$HOSTNAME" != warthog ]; then
return
fi
status=$(acpi -a | cut -d':' -f2)
battery=$(acpi -b | cut -d, -f2 | sed -e 's/[^0-9]//g')
if [[ $status == " on-line" ]]; then
echo -n $(icon ac2 brightblue) ${battery}%
elif [[ $battery -le 20 ]]; then
echo -n $(icon battery_horz1 red) ${battery}%
elif [[ $battery -le 65 ]]; then
echo -n $(icon battery_horz2 yellow) ${battery}%
else
echo -n $(icon battery_horz3 green) ${battery}%
fi
}
hc pad $monitor $panel_height hc pad $monitor $panel_height
{ {
@ -151,7 +170,7 @@ hc pad $monitor $panel_height
right="" right=""
# custom functions # custom functions
for func in cpu; do for func in cpu battery; do
right="${right} $(${func})" right="${right} $(${func})"
done done