Make volume.sh more maintainable, remove head call
This commit is contained in:
@@ -13,10 +13,11 @@ case $BLOCK_BUTTON in
|
||||
5) amixer -q -D $MIXER sset $INSTANCE ${STEP}- unmute ;; # scroll down, decrease
|
||||
esac
|
||||
|
||||
INFO=$(amixer -D $MIXER get $INSTANCE)
|
||||
INFO="amixer -D $MIXER get $INSTANCE"
|
||||
|
||||
volume() {
|
||||
VOLUME=$(echo $INFO | sed -nr 's/.*\[([0-9]*)%\].*/\1/p' | head -n 1)
|
||||
VOLUME="$(${INFO} | \
|
||||
awk '/\[[0-9]+%\]/ { print substr($5, 2, length($5) - 3); exit }')"
|
||||
}
|
||||
|
||||
symbol() {
|
||||
@@ -32,7 +33,7 @@ symbol() {
|
||||
|
||||
setOutput() {
|
||||
# If sound is not muted
|
||||
if [ -n "$(echo $INFO | sed -nr 's/(\[on\])/\1/p')" ]; then
|
||||
if [ -n "$(${INFO} | sed -nr 's/(\[on\])/\1/p')" ]; then
|
||||
COLOR="#FFF"
|
||||
volume
|
||||
symbol
|
||||
|
||||
Reference in New Issue
Block a user