summaryrefslogtreecommitdiff
path: root/daemons/dcheck_battery
blob: 343bc4abd64257ac2d2728ddadebfce7219af780 (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 -s "Battery" "Critically low: ${percent}%"
    fi

    sleep 120
done