Skip to content

Instantly share code, notes, and snippets.

@zviryatko
Created June 19, 2015 08:29
Show Gist options
  • Save zviryatko/642497fd7578e7367a1c to your computer and use it in GitHub Desktop.
Save zviryatko/642497fd7578e7367a1c to your computer and use it in GitHub Desktop.
Switch PulseAudio master channel between multiple sound cards
#!/bin/bash
# Switch PulseAudio master channel between multiple sound cards
ENABLED=$(pacmd list-sinks | grep -A1 '* index' | grep 'name' | awk '{print $2}' | tr -d '<->')
DEVICE=$(pacmd list-sinks | grep 'name:' | awk '{print $2}' | tr -d '<->' | grep -v $ENABLED)
pactl set-default-sink $DEVICE
pactl set-default-source "$DEVICE.monitor"
INPUTS=($(pacmd list-sink-inputs | grep index | awk '{print $2}'))
for i in ${INPUTS[*]}; do pacmd move-sink-input $i $DEVICE &> /dev/null; done
qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster "PulseAudio::Playback_Devices=:1" "$DEVICE" 2>&1 > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment