blob: c08367093bc8dcc562543aca41d8bc4ee059e9b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/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
[ "$state" != "discharging" ] && exit 0
if [ "$percentage" -le 5 ]; then
notify-send "Battery very low."
elif [ "$percentage" -le 15 ]; then
notify-send "Battery low."
fi
|