diff options
Diffstat (limited to 'scripts/daemons/bat-checkd')
| -rwxr-xr-x | scripts/daemons/bat-checkd | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/daemons/bat-checkd b/scripts/daemons/bat-checkd new file mode 100755 index 0000000..2c272b8 --- /dev/null +++ b/scripts/daemons/bat-checkd @@ -0,0 +1,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 |
