summaryrefslogtreecommitdiff
path: root/batterymon.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-12-30 12:36:16 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-12-30 12:36:16 -0500
commita9d284811255a1982ff2587467a77a27a82dd74a (patch)
tree32992285f5722501a9581634f3c2f245dc4b3f7e /batterymon.sh
parente3f67d934025ba0c6853e8b8cdaddb97dbac1283 (diff)
Create batterymon, a program that will monitor the battery, and run a command if discharging and below a certain percent.
Diffstat (limited to 'batterymon.sh')
-rw-r--r--batterymon.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/batterymon.sh b/batterymon.sh
new file mode 100644
index 0000000..6396c2d
--- /dev/null
+++ b/batterymon.sh
@@ -0,0 +1,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