From 435f96cf05fac2dd4cd233039c998a5464bedaca Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 11 Dec 2017 11:26:21 -0500 Subject: pavol: show mute status in output --- dot/local/bin/pavol | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'dot') diff --git a/dot/local/bin/pavol b/dot/local/bin/pavol index c88437c..cceda70 100755 --- a/dot/local/bin/pavol +++ b/dot/local/bin/pavol @@ -26,14 +26,17 @@ mute() # uses $sink esac } -show_volume_line() # uses $sink +show_volume_line() { show_sink_line Volume; } +show_mute_line() { show_sink_line Mute; } + +show_sink_line() # uses $sink { - local want_next= + local wanted_line="$1" want_next= pactl list sinks | while read line; do case "$line" in "Name: $sink") want_next=1 ;; 'Name: '*) want_next= ;; - 'Volume: '*) + "${wanted_line}: "*) [ "$want_next" ] || continue echo "$line" break @@ -59,10 +62,25 @@ show_volume_number() # uses $sink fi } +show_mute_bool() +{ + set -- $(show_mute_line) + echo "$2" +} + +show_status() +{ + volume=$(show_volume_number) + case "$(show_mute_bool)" in + "yes") printf '%s (muted)\n' "$volume" ;; + "no") echo "$volume" ;; + esac +} + case "$1" in [0-9]*) set_volume "$1" ;; [-+*/][0-9]*) set_volume $(( $(show_volume_number) $1 )) ;; - '') show_volume_number ;; + '') show_status ;; --mute=*) mute "${1%mute=}" ;; --mute) mute "$2" ;; *) die 'usage' ;; -- cgit v1.2.3