aboutsummaryrefslogtreecommitdiff
path: root/local/bin/battery-low-notify
blob: 605ea91217d4dae0b4884a41e76a79810809f377 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh

battery_dir='/sys/class/power_supply/BAT0'

[ ! -d "$battery_dir" ] && exit 1

if [ "$(cat "$battery_dir/status")" != 'Charging' ]
then
    capacity="$(cat "$battery_dir/capacity")"
    [ "$capacity" -lt 15 ] &&
        notify-send -u critical "Battery low: $capacity%"
fi

exit 0