summaryrefslogtreecommitdiff
path: root/batterymon.sh
blob: 6396c2deca4cc64829f185a7cec14d8e67ae8e6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash

thresh=$1
shift

while true; do
    num=`acpi|sed -nr '/Discharging/s/.*, ([0-9]*)%,.*/\1/p'`
    num=${num:-100}
    if (( "$num" < "$thresh" )); then
	eval "$*"
    else
	sleep 1
    fi
done