scripts

various script and utils
git clone git://z3bra.org/scripts
Log | Files | Refs

commit cbaecede0900106f1e1158fa6cd638bbcf4a4390
parent e15923a2d4ccf656070c9b6e7307bb58e388f271
Author: z3bra <willy@mailoo.org>
Date:   Thu May 22 16:17:41 +0200

Merge branch 'master' of z3bra.org:scripts

Diffstat:
battery | 10++++++++--
dualhead | 2+-
hmgr | 2++
mkbar | 10++++++----
4 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/battery b/battery @@ -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 () { diff --git a/dualhead b/dualhead @@ -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 diff --git a/hmgr b/hmgr @@ -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 diff --git a/mkbar b/mkbar @@ -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}' @@ -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 '+' @@ -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)  "