diff options
author | Andrew Cady <d@jerkface.net> | 2017-12-11 11:26:21 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2017-12-11 11:26:21 -0500 |
commit | 435f96cf05fac2dd4cd233039c998a5464bedaca (patch) | |
tree | ace4aaa6ad274dbe9be33c2691c0972d581efd29 /dot/local | |
parent | a3318dfa672fd5d592ac5b4328d778a12234008e (diff) |
pavol: show mute status in output
Diffstat (limited to 'dot/local')
-rwxr-xr-x | dot/local/bin/pavol | 26 |
1 files changed, 22 insertions, 4 deletions
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 | |||
26 | esac | 26 | esac |
27 | } | 27 | } |
28 | 28 | ||
29 | show_volume_line() # uses $sink | 29 | show_volume_line() { show_sink_line Volume; } |
30 | show_mute_line() { show_sink_line Mute; } | ||
31 | |||
32 | show_sink_line() # uses $sink | ||
30 | { | 33 | { |
31 | local want_next= | 34 | local wanted_line="$1" want_next= |
32 | pactl list sinks | while read line; do | 35 | pactl list sinks | while read line; do |
33 | case "$line" in | 36 | case "$line" in |
34 | "Name: $sink") want_next=1 ;; | 37 | "Name: $sink") want_next=1 ;; |
35 | 'Name: '*) want_next= ;; | 38 | 'Name: '*) want_next= ;; |
36 | 'Volume: '*) | 39 | "${wanted_line}: "*) |
37 | [ "$want_next" ] || continue | 40 | [ "$want_next" ] || continue |
38 | echo "$line" | 41 | echo "$line" |
39 | break | 42 | break |
@@ -59,10 +62,25 @@ show_volume_number() # uses $sink | |||
59 | fi | 62 | fi |
60 | } | 63 | } |
61 | 64 | ||
65 | show_mute_bool() | ||
66 | { | ||
67 | set -- $(show_mute_line) | ||
68 | echo "$2" | ||
69 | } | ||
70 | |||
71 | show_status() | ||
72 | { | ||
73 | volume=$(show_volume_number) | ||
74 | case "$(show_mute_bool)" in | ||
75 | "yes") printf '%s (muted)\n' "$volume" ;; | ||
76 | "no") echo "$volume" ;; | ||
77 | esac | ||
78 | } | ||
79 | |||
62 | case "$1" in | 80 | case "$1" in |
63 | [0-9]*) set_volume "$1" ;; | 81 | [0-9]*) set_volume "$1" ;; |
64 | [-+*/][0-9]*) set_volume $(( $(show_volume_number) $1 )) ;; | 82 | [-+*/][0-9]*) set_volume $(( $(show_volume_number) $1 )) ;; |
65 | '') show_volume_number ;; | 83 | '') show_status ;; |
66 | --mute=*) mute "${1%mute=}" ;; | 84 | --mute=*) mute "${1%mute=}" ;; |
67 | --mute) mute "$2" ;; | 85 | --mute) mute "$2" ;; |
68 | *) die 'usage' ;; | 86 | *) die 'usage' ;; |