summaryrefslogtreecommitdiff
path: root/scripts/daemons/bat-checkd
blob: 2c272b8d12c37a7dc1bfaaa57ce8b68ff75a77b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh

# FIXME: hardcoded battery
BAT="/sys/class/power_supply/BAT0"

while true; do
    percent=$(cat "${BAT}/capacity")
    status=$(cat "${BAT}/status")

    # Only notify if battery is low AND not charging
    if [ "${status}" = "Discharging" ] && [ "${percent}" -lt 7 ]; then
        nsend -s "Battery" "Critically low: ${percent}%"
    fi

    sleep 120
done