scripts

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

commit e87293d7be54fc7697bac9462bbcac9ffc6725c5
parent 78e3d0b5852605ab97995459201119c5c7bdb02c
Author: z3bra <willy@mailoo.org>
Date:   Tue Nov  4 16:33:45 +0100

Smarter volume channel detection

Diffstat:
popup | 4+++-
volume | 14++++++++------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/popup b/popup @@ -6,6 +6,8 @@ TEXT='none' SLEEP=3 +ALSACHANNEL=$(amixer | sed "1s/^.*'\(.*\)'.*$/\1/p;d") + # bar options font='-*-stlarch-medium-r-*-*-10-*-*-*-*-*-*-*' font="$font,-*-gohufont-medium-*-*--11-*-*-*-*-*-iso10646-1" @@ -40,7 +42,7 @@ loop() { } getvol() { - vol=`amixer sget Master | + vol=`amixer sget $ALSACHANNEL | sed -n 's/^.*\[\([0-9/]*%\)\].*\[\(o[nf]\+\)\]$/\1 (\2)/p' | uniq` case $1 in diff --git a/volume b/volume @@ -2,6 +2,8 @@ # # z3bra - (c) wtfpl 2014 +CHANNEL=$(amixer | sed "1s/^.*'\(.*\)'.*$/\1/p;d") + usage () { cat <<EOF usage: $(basename $0) [-hsla] [-+!] @@ -16,11 +18,11 @@ EOF } level() { - amixer get Master | sed -n 's/^.*\[\([0-9]\+%\).*$/\1/p' | uniq + amixer get $CHANNEL | sed -n 's/^.*\[\([0-9]\+%\).*$/\1/p' | uniq } state() { - amixer get Master | sed -n 's/^.*\[\(o[nf]\+\)]$/\1/p' | uniq + amixer get $CHANNEL | sed -n 's/^.*\[\(o[nf]\+\)]$/\1/p' | uniq } # print out level and state if no argument is given @@ -30,8 +32,8 @@ case $1 in -h) usage ;; -s) state ;; -l) level ;; - +) amixer set Master 5%+ >/dev/null;; - -) amixer set Master 5%- >/dev/null;; - !) amixer set Master toggle >/dev/null;; - *) amixer set Master $1 >/dev/null;; + +) amixer set $CHANNEL 5%+ >/dev/null;; + -) amixer set $CHANNEL 5%- >/dev/null;; + !) amixer set $CHANNEL toggle >/dev/null;; + *) amixer set $CHANNEL $1 >/dev/null;; esac