tGet battery name automatically - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 1e6a7dafdc61d7c52fbfabf2eb750da9c9db655d
(DIR) parent 4b27c9d8d9dfa8c599ba02f550d6fd48bacc258f
(HTM) Author: z3bra <willy@mailoo.org>
Date: Mon, 12 May 2014 19:36:45 +0200
Get battery name automatically
Diffstat:
M mkbar | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/mkbar b/mkbar
t@@ -7,8 +7,11 @@
refresh_rate=0.75 # how often will the bar update
datefmt="%H:%M - %d %b" # date time format
maildir=~/var/mail/INBOX/new # where do new mails arrive ?
-battery=1 # battery index
alsactl=Master # which alsa channel to display
+#battery=BAT0 # battery index
+# find battery name in a smart way
+battery=$(ls /sys/class/power_supply | grep BAT)
+
barch=''
barfg='%{F#ffffffff}'
t@@ -28,8 +31,8 @@ mails() {
}
battery() {
- BATC=/sys/class/power_supply/BAT${battery}/capacity
- BATS=/sys/class/power_supply/BAT${battery}/status
+ BATC=/sys/class/power_supply/${battery}/capacity
+ BATS=/sys/class/power_supply/${battery}/status
# prepend percentage with a '-' if discharging, '+' otherwise
#test "`cat $BATS`" = "Discharging" && echo -n '-' || echo -n '+'