blob: ed07119ebecadba4f321cf5a7387f35dd8417a7d (
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
35
36
37
|
#!/bin/sh
last="NONE"
low=15
critical=5
bat="BAT1"
while true; do
battery="/sys/class/power_supply/$bat"
if [ -d $battery ]; then
capacity=$(cat $battery/capacity)
status=$(cat $battery/status)
if [ "$last" != "FULL" ] && [ "$status" = "Full" ]; then
notify-send "Power" "Battery is full"
last="FULL"
fi
# If low and discharging
if [ "$last" != "LOW" ] && [ "$status" = "Discharging" ] && \
[ $capacity -le $low ]; then
notify-send "Power" "Battery warning: $capacity%"
last=LOW
fi
# If critical and discharging
if [ "$status" = "Discharging" ] && [ $capacity -le $critical ]; then
notify-send "Power" "Battery critical: $capacity%"
last=CRITICAL
fi
fi
sleep 60
done
|