blob: 7aaaede85483c3e74da9b92f3daf9b27b0700c63 (
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
|
#!/bin/sh
if [ ! "$1" = "--silent" ]; then
if [ ! "$1" = "--say" ]; then
message="beep beep - low battery"
else
message=$2
fi
fi
ntf() {
notify-send "Low battery: $batlvl%" "Please plug in computer" -u critical -t 15000
if [ ! "$message" = "--silent" ]; then
echo "$message" | espeak
fi
}
while true ; do
acstat=$(acpi | awk '{print $3}' | rev | cut -c 2- | rev)
batlvl=$(acpi | awk '{print $4}' | rev | cut -c 3- | rev)
if [ "$batlvl" -lt 15 ]; then
while [ "$acstat" = "Discharging" ]; do
ntf
sleep 20
acstat=$(acpi | awk '{print $3}' | rev | cut -c 2- | rev)
batlvl=$(acpi | awk '{print $4}' | rev | cut -c 3- | rev)
if [ "$acstat" = "Charging" ]; then
break
fi
done
fi
sleep 240
done
|