summaryrefslogtreecommitdiff
path: root/batterymon.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-12-03 13:27:04 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-12-03 13:27:04 -0500
commita36ecefba2a3d54feba3206e058df5c33aba4af9 (patch)
tree855f0f69c16c615a6cf72f7b48acbe23d4854f2c /batterymon.sh
parent05d7b5e619f9c8488b7a13057dac92b37f2cbfcb (diff)
touch up {battery,temp}mon
Diffstat (limited to 'batterymon.sh')
-rw-r--r--batterymon.sh21
1 files changed, 13 insertions, 8 deletions
diff --git a/batterymon.sh b/batterymon.sh
index 6396c2d..34e7faa 100644
--- a/batterymon.sh
+++ b/batterymon.sh
@@ -1,14 +1,19 @@
#!/bin/bash
+if [[ $# -ne 2 ]]; then
+ echo "Usage: $0 THRESHOLD COMMAND"
+fi
+
thresh=$1
-shift
+cmd=$2
+
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
+ num=`acpi|sed -nr '/Discharging/s/.*, ([0-9]*)%,.*/\1/p'`
+ num=${num:-100}
+ if (( "$num" < "$thresh" )); then
+ eval "$cmd"
+ else
+ sleep 1
+ fi
done