summaryrefslogtreecommitdiff
path: root/batterylow
blob: 2086cb24a74624fbc519771133c3ee3365632dc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh
# This script sends notifications when battery is low.

# those variables may be unnecessary
export DISPLAY=:0
export HOME=/home/filipek

percentage=$(upower -i "$(upower -e | grep BAT)" |
    awk '/percentage/ {gsub(/%/, "", $2); print $2}')

if [ "$percentage" -le 5 ]; then
    notify-send "Battery very low."
elif [ "$percentage" -ge 14 ] && [ "$percentage" -le 15 ]; then
    notify-send "Battery low."
fi