21 lines
401 B
Bash
21 lines
401 B
Bash
#!/usr/bin/bash
|
|
export DISPLAY=:0
|
|
CAPACITY=$(cat /sys/class/power_supply/BAT0/capacity)
|
|
|
|
# perform notifications
|
|
if [[ $CAPACITY -lt 20 ]]
|
|
then
|
|
MSG="Battery low: $CAPACITY%";
|
|
/usr/bin/notify-send "$MSG";
|
|
fi
|
|
|
|
# suspend system when battery is low
|
|
if [[ $CAPACITY -ge 0 && $CAPACITY -lt 10 ]]
|
|
then
|
|
MSG="Should suspend now, battery critical: $CAPACITY";
|
|
/usr/bin/notify-send "$MSG";
|
|
fi
|
|
|
|
|
|
|