From 1dc3bf18cbcc94b357e70f95ec2810fc817069b3 Mon Sep 17 00:00:00 2001 From: Cian Bagshaw Date: Sat, 11 Mar 2023 00:47:50 +0000 Subject: [PATCH] Improved gvol Re-wrote most of the shell-script for getting volume info, to make it more efficient. --- .local/bin/gvol | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/.local/bin/gvol b/.local/bin/gvol index e26c1bc..29f43ba 100755 --- a/.local/bin/gvol +++ b/.local/bin/gvol @@ -1,19 +1,11 @@ #!/bin/sh # gvol - get volume of alsa control using amixer, with $1 as the control name, -# defaults to Master if blank +# defaulting to Master if blank -if [ $# == 1 ] -then - CONTROL=$1 -else - CONTROL=Master -fi +[ -z "$1" ] && CONTROL=Master || CONTROL="$1" -VOL=$(amixer get $CONTROL | grep Left:) +VOL=$(amixer get $CONTROL | grep -m1 "%") -if [ $(echo $VOL | awk '{print $6}') == "[off]" ] -then - echo MUTE -else - echo $(echo $VOL | awk '{print $5}' | tr -d []) -fi +[ $(grep -Fo "[on]" <<< "$VOL") ] \ + && grep -o "[0-9]*%" <<< "$VOL" \ + || echo MUTE -- 2.20.1