21 lines
506 B
Bash
Executable File
21 lines
506 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
LOW_THRESHOLD=15
|
|
CRITICAL_THRESHOLD=5
|
|
|
|
charge=$(cat /sys/class/power_supply/BAT0/capacity)
|
|
state=$(cat /sys/class/power_supply/ACAD/online)
|
|
|
|
echo "charging: $(state)"
|
|
|
|
if [[ "$state" == "0" ]]; then
|
|
if [[ $charge -le $CRITICAL_THRESHOLD ]]; then
|
|
echo "critical"
|
|
notify-send -t 10000 -u critical "Battery critically low! ($charge%)"
|
|
elif [[ $charge -le $LOW_THRESHOLD ]]; then
|
|
echo "low"
|
|
notify-send -u normal "Battery low ($charge%)"
|
|
fi
|
|
fi
|
|
|