summaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
authorsinanmohd <pcmsinan@gmail.com>2023-03-17 17:35:24 +0530
committersinanmohd <pcmsinan@gmail.com>2023-03-17 17:50:52 +0530
commit8a0bb2c9e72f28df9034f8c9a23270882c143ef2 (patch)
treea5db9bcd22ca7096865be860682900720c5afaed /.local/bin
parent4f06cc87a2a26b3f7be22268f095c00c88bf49f9 (diff)
audio_cyclesink: don't do anything if only one sink is available
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/audio_cyclesink21
1 files changed, 13 insertions, 8 deletions
diff --git a/.local/bin/audio_cyclesink b/.local/bin/audio_cyclesink
index 52b2661..3726f70 100755
--- a/.local/bin/audio_cyclesink
+++ b/.local/bin/audio_cyclesink
@@ -56,22 +56,27 @@ cycle_sink()
do
case "$sink" in
\**)
- default_sink="${sinks#* }"
+ default_sink="${sink##* }"
;;
*)
- if [ -n "$default_sink" ]
- then
- next_sink="${sink# }"
- break
- fi
+ [ -z "$default_sink" ] &&
+ continue
+
+ next_sink="${sink##* }"
+ break
;;
esac
done
# if default sink is last one use first sink
- : "${next_sink:="${sinks%%:*}"}"
+ if [ -z "$next_sink" ]
+ then
+ next_sink="${sinks%%:*}"
+ next_sink="${next_sink##* }"
+ fi
- wpctl set-default "$next_sink"
+ [ "$next_sink" != "$default_sink" ] &&
+ wpctl set-default "$next_sink"
}
wpctl status | parse_sinks | cycle_sink