#!/bin/bash source stdlib.sh source sink_names.sh while getopts 'vs' opt ; do case "$opt" in v) verbosity=VERBOSE ;; s) verbosity=SILENT ;; esac done newSink=${@:$OPTIND:1} if [ -z "$newSink" ]; then error "Usage: $0 [OPTION] " error " -v print verbose output" error " -s don't print any output" error "Valid sinks:" error "$(pactl list short sinks)" exit 1 fi case "$newSink" in 'bluetooth') newSink=`pactl list short sinks | grep "$bluetooth_sink_name" | cut -f 1` ;; 'analog') newSink=`pactl list short sinks | grep analog-stereo | cut -f 1` ;; 'hdmi') newSink=`pactl list short sinks | grep hdmi-stereo-extra1 | cut -f 1` ;; esac pactl list short sink-inputs 2> >(error) |while read stream; do streamId=$(echo $stream|cut '-d ' -f1) log "moving stream $streamId" pactl move-sink-input "$streamId" "$newSink" > >(log) 2> >(error) done pacmd set-default-sink "$newSink" > >(log) 2> >(error) # to change toolbar item