blob: 38f427248bb5f5ac3dc8491dc32b07cf569ab058 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/bin/sh
pane() {
battery_level=$(cat /sys/class/power_supply/BAT*/capacity)
state=$(cat /sys/class/power_supply/BAT0/status)
if [ $state == "Charging" ]; then
echo -e +$battery_level%
else
echo -e $battery_level%
fi
}
notifs() {
while true
do
battery_level=$(cat /sys/class/power_supply/BAT*/capacity)
state=$(cat /sys/class/power_supply/BAT*/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
done
}
case "$1" in
n)
notifs;;
*)
pane;;
esac
|