From: Cian Bagshaw Date: Wed, 7 Jun 2023 18:35:08 +0000 (+0100) Subject: Re-Wrote gvol X-Git-Url: https://tests.cianb.xyz/?a=commitdiff_plain;h=4aa91ec9a8031bd77e238b7b55c98a4a57aaa8a4;p=dotFiles Re-Wrote gvol It now parses amixer output with a single highly efficient sed command. Also, removed all bashisms. --- diff --git a/.local/bin/gvol b/.local/bin/gvol index 29f43ba..edbf5ba 100755 --- a/.local/bin/gvol +++ b/.local/bin/gvol @@ -2,10 +2,7 @@ # gvol - get volume of alsa control using amixer, with $1 as the control name, # defaulting to Master if blank -[ -z "$1" ] && CONTROL=Master || CONTROL="$1" - -VOL=$(amixer get $CONTROL | grep -m1 "%") - -[ $(grep -Fo "[on]" <<< "$VOL") ] \ - && grep -o "[0-9]*%" <<< "$VOL" \ - || echo MUTE +amixer get \ + $( [ -z "$1" ] && echo "Master" || echo "$1") \ + | sed -e '/\[on\]/ { s/\].*//; s/.*\[//; p; q }' \ + -e '/\[off\]/ { s/^.*$/MUTE/; p; q }' -n