#!/bin/sh . ../mpanel.subr align="right" background="$(color 9)" foreground="$(color 3)" clickFunc="toggle flag" waitFunc="sleep 5" notify="" flag=true print_batt() { level="$(cat /sys/class/power_supply/BAT1/capacity)" if [ "$level" -ge "100" ]; then SYMBOL="" elif [ "$level" -ge "90" ]; then SYMBOL="" elif [ "$level" -ge "80" ]; then SYMBOL="" elif [ "$level" -ge "70" ]; then SYMBOL="" elif [ "$level" -ge "60" ]; then SYMBOL="" elif [ "$level" -ge "50" ]; then SYMBOL="" elif [ "$level" -ge "40" ]; then SYMBOL="" elif [ "$level" -ge "30" ]; then SYMBOL="" elif [ "$level" -ge "20" ]; then SYMBOL="" notify="" elif [ "$level" -ge "10" ]; then SYMBOL="" if [ "$notify" = "" ]; then notify-send --urgency=normal "Battery Low!" fi notify="low" elif [ "$level" -ge "0" ]; then SYMBOL="" if [ "$notify" = "" ] || [ "$notify" = "low" ]; then notify-send --urgency=critical "Battery Critically Low!" fi notify="critical" fi if [ "$(cat /sys/class/power_supply/BAT1/status)" = "Charging" ]; then SYMBOL="$SYMBOL" else SYMBOL="$SYMBOL" fi if [ "$flag" = "true" ]; then output=" $SYMBOL $(cat /sys/class/power_supply/BAT1/capacity)% " else output=" $SYMBOL " fi echo "$output" } loop print_batt