1#!/bin/bash23declare -i sinks_count=`pacmd list-sinks | grep -c index:[[:space:]][[:digit:]]`45if [ $sinks_count -eq 0 ] ; then6exit7fi89declare -i active_sink_index=`pacmd list-sinks | sed -n -e 's/\*[[:space:]]index:[[:space:]]\([[:digit:]]\)/\1/p'`1011active_index_position_found=012let next_sink_index=-113while read index ;14do15declare -i ind=($(echo $index | tr -dc '[0-9]+'))16if [ $next_sink_index -lt 0 ] ; then17export next_sink_index=$ind18fi19if [ $active_index_position_found -eq 1 ] ; then20export next_sink_index=$ind21break;22fi23if [ $active_sink_index -eq $ind ] ; then24export active_index_position_found=125fi26done < <(pacmd list-sinks | grep index:[[:space:]][[:digit:]])2728#change the default sink29pacmd "set-default-sink ${next_sink_index}"3031#move all inputs to the new sink32for app in $(pacmd list-sink-inputs | sed -n -e 's/index:[[:space:]]\([[:digit:]] \)/\1/p');33do34pacmd "move-sink-input $app $next_sink_index"35done3637#display notification38declare -i ndx=039pacmd list-sinks | sed -n -e 's/device.description[[:space:]]=[[:space:]]"\(.*\)"/\1/p' | while read line;40do41if [ $next_sink_index -eq $ndx ] ; then42#notify-send -i notification-audio-volume-high "Sound output switched to" "$line"43notify-send "Sound output switched" "$line"44exit45fi46ndx+=147done;