#!/bin/bash # # Cycle between the current PulseAudio sinks. # Based on https://askubuntu.com/a/740002 # # Usage: ./cycle_pa_sinks ################################################################################ new_sink=$(pacmd list-sinks | awk '/index/{print; i=1} i&&/device.product.name/{print; i=0}' | tee /dev/stdout | grep -m1 -A3 "* index" | tail -2) new_sink_idx=$(echo "$new_sink" | head -n1 | cut -c12-) new_sink_name=$(echo "$new_sink" | tail -n1 | cut -f2 -d'"') msg="Setting default sink to: #$new_sink_idx ($new_sink_name)" if [ -t 0 ]; then echo "$msg" else notify-send -u low -t 2000 "$msg" fi pacmd set-default-sink $new_sink_idx