tScript that beeps on low battery - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 947dd058da448167406fb3904a78459d825f19b8
(DIR) parent 75a621289739be74082421274411ba446543c0a7
(HTM) Author: z3bra <willy@mailoo.org>
Date: Tue, 28 Jan 2014 17:16:37 +0100
Script that beeps on low battery
Diffstat:
A battery.sh | 17 +++++++++++++++++
1 file changed, 17 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/battery.sh b/battery.sh
t@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# Beep once when under 15%, twice under 10, and three times under 5%
+# Under 3%, you're asked to shutdown
+
+BATC=`cat /sys/class/power_supply/BAT1/capacity`
+BATS=`cat /sys/class/power_supply/BAT1/status`
+
+test "$BATS" == "Charging" && exit
+
+if test $BATC -gt 3; then
+ test $BATC -lt 15 && beep -f1000 -l200 -D50
+ test $BATC -lt 10 && beep -f1000 -l200 -D50
+ test $BATC -lt 5 && beep -f1000 -l200 -D50
+else
+ test $BATC -lt 3 && espeak 'Battery is empty, please shut down'
+fi