Make volume.sh more maintainable, remove head call

This commit is contained in:
Riyyi
2018-04-10 11:05:35 +02:00
parent c542356802
commit 5d3966cc19
+4 -3
View File
@@ -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