Browse Source

Make volume.sh more maintainable, remove head call

master
Riyyi 7 years ago
parent
commit
5d3966cc19
  1. 11
      .scripts/wm/volume.sh

11
.scripts/wm/volume.sh

@ -13,10 +13,11 @@ case $BLOCK_BUTTON in
5) amixer -q -D $MIXER sset $INSTANCE ${STEP}- unmute ;; # scroll down, decrease 5) amixer -q -D $MIXER sset $INSTANCE ${STEP}- unmute ;; # scroll down, decrease
esac esac
INFO=$(amixer -D $MIXER get $INSTANCE) INFO="amixer -D $MIXER get $INSTANCE"
volume() { 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() { symbol() {
@ -31,13 +32,13 @@ symbol() {
} }
setOutput() { setOutput() {
# If sound is not muted # 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" COLOR="#FFF"
volume volume
symbol symbol
VOLUME="$VOLUME%" VOLUME="$VOLUME%"
else else
COLOR="#676E7D" COLOR="#676E7D"
VOLUME="MUTE" VOLUME="MUTE"
SYMBOL="" SYMBOL=""

Loading…
Cancel
Save