blob: 85cdf5df59b6a35de68d72b994e710ac6ded7bc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/bin/sh
# This script sends notifications when battery is low,
# but only while discharging.
battery=$(upower -e | grep BAT | head -n 1)
percentage=$(upower -i "$battery" |
awk '/percentage/ {gsub(/%/, "", $2); print $2}')
state=$(upower -i "$battery" |
awk '/state/ {print $2}')
# Only notify if the battery is discharging
if [ "$state" != "discharging" ]; then
exit 0
fi
if [ "$percentage" -le 5 ]; then
notify-send "Battery very low."
elif [ "$percentage" -le 15 ]; then
notify-send "Battery low."
fi
|