blob: 547b976c07af2e4bf8480fda5fa29941401c932d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#!/bin/bash
while true
do
battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
state=$(cat /sys/class/power_supply/BAT0/status)
if [ $battery_level -ge 90 ] && [ $state == "Charging" ]; then
notify-send 'Pull the plug!' $battery_level%
elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then
notify-send 'Plug me!' $battery_level%
elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then
notify-send -u critical 'Plug me NOW!' $battery_level%
fi
sleep 300 # 300 seconds or 5 minutes
done
|