From a9d284811255a1982ff2587467a77a27a82dd74a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Dec 2011 12:36:16 -0500 Subject: Create batterymon, a program that will monitor the battery, and run a command if discharging and below a certain percent. --- batterymon.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 batterymon.sh (limited to 'batterymon.sh') 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 -- cgit v1.2.3