From 8a0bb2c9e72f28df9034f8c9a23270882c143ef2 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Fri, 17 Mar 2023 17:35:24 +0530 Subject: audio_cyclesink: don't do anything if only one sink is available --- .local/bin/audio_cyclesink | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to '.local/bin') 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 -- cgit v1.2.3