tMerge branch 'master' of z3bra.org:scripts - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit cbaecede0900106f1e1158fa6cd638bbcf4a4390
(DIR) parent e15923a2d4ccf656070c9b6e7307bb58e388f271
(HTM) Author: z3bra <willy@mailoo.org>
Date: Thu, 22 May 2014 16:17:41 +0200
Merge branch 'master' of z3bra.org:scripts
Diffstat:
M battery | 10 ++++++++--
M dualhead | 2 +-
M hmgr | 2 ++
M mkbar | 10 ++++++----
4 files changed, 17 insertions(+), 7 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 () {
(DIR) diff --git a/dualhead b/dualhead
t@@ -13,5 +13,5 @@ case "$1" in
xrandr --output LVDS1 --primary --auto --output VGA1 --off;;
list)
xrandr | grep '\<connected\>' | cut -d\ -f1;;
- *) echo `basename $0` '{left|right|same|screen|laptop|list}';;
+ *) echo `basename $0` '{left|right|dup|screen|laptop|list}';;
esac
(DIR) diff --git a/hmgr b/hmgr
t@@ -66,6 +66,8 @@ list() {
check() {
found=0
+ test ! -f ${cin} && echo "cannot find file ${cin}" && exit 1
+
for dir in ${basedir}/*; do
for file in ${dir}/*; do
if diff $file ${cin} >/dev/null; then
(DIR) diff --git a/mkbar b/mkbar
t@@ -7,8 +7,10 @@
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 +30,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 '+'
t@@ -164,7 +166,7 @@ fi
buf="${buf}$(makebar $(volume)) "
# Show battery status if there is a battery (U DONT SAY)
-test -d /sys/class/power_supply/BAT${battery} &&
+test -n "$(battery)" &&
buf="${buf}%{F#ffef79ae} %{F-} $(makebar $(battery)) "
buf="${buf}%{F#ffb3b3b3} %{F-} $(clock) "