tNow detect battery name - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 4b27c9d8d9dfa8c599ba02f550d6fd48bacc258f
(DIR) parent eeb792c4e11e541a6cf4afd77ac690428dff1619
(HTM) Author: z3bra <willy@mailoo.org>
Date: Mon, 12 May 2014 19:36:02 +0200
Now detect battery name
Diffstat:
M battery | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/battery b/battery
t@@ -2,9 +2,15 @@
#
# beep once per level. does not beep when charging
+# get battery name
+BATN=$(ls /sys/class/power_supply/ | grep BAT)
+
+# exit if no battery available
+test -z "$BATN" && exit 1
+
# get battery level and status (charging or not)
-BATC=`cat /sys/class/power_supply/BAT1/capacity`
-BATS=`cat /sys/class/power_supply/BAT1/status`
+BATC=`cat /sys/class/power_supply/$BATN/capacity`
+BATS=`cat /sys/class/power_supply/$BATN/status`
# Run this if sound is enabled
sbell () {