From 4aa91ec9a8031bd77e238b7b55c98a4a57aaa8a4 Mon Sep 17 00:00:00 2001 From: Cian Bagshaw Date: Wed, 7 Jun 2023 19:35:08 +0100 Subject: [PATCH] Re-Wrote gvol It now parses amixer output with a single highly efficient sed command. Also, removed all bashisms. --- .local/bin/gvol | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 -- 2.20.1