summaryrefslogtreecommitdiff
path: root/bin/.bin/bat
blob: 72e30a2862d44f4daba0e370f243ae4693ff41fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh

while true
do
    battery_level=$(cat /sys/class/power_supply/BAT*/capacity)
    state=$(cat /sys/class/power_supply/BAT*/status)
    if [ $battery_level -ge 90 ] && [ $state == "Charging" ]; then
       notify-send 'Pull the plug!' $battery_level%
    elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then
       notify-send 'Plug me!' $battery_level%
    elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then
       notify-send -u critical 'Plug me NOW!' $battery_level%
    fi
    sleep 300
done