summaryrefslogtreecommitdiff
path: root/daemons/dcheck_battery
blob: 627acbf95fad0a50c5364ce50a22c4023c2c3642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash

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 -c "Battery" "Critically low: ${percent}%"
    fi

    sleep 120
done