Skip to content

Instantly share code, notes, and snippets.

@varqox
Created March 1, 2024 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save varqox/9830fdc5e9599838b9c882eb268b7a78 to your computer and use it in GitHub Desktop.
Save varqox/9830fdc5e9599838b9c882eb268b7a78 to your computer and use it in GitHub Desktop.
Select and create combined sink node with Pipewire and set it as default Pulseaudio sink (output)
#!/bin/bash
set -euo pipefail
list_sinks() {
pw-cli list-objects Node | grep -P '^\s+id |^\s+node\.name|^\s+media\.class = "Audio/Sink"' | grep 'media\.class' -B 2 --no-group-separator | paste -sd' \n' | sed 's/^\s*id [0-9]*, type .*node\.name = "\([^"]*\)".*/\1/' | (grep -vP "^($1)$" || true)
}
pactl unload-module module-combine-sink 2> /dev/null
selected_names_regex=''
selected_names=""
while true; do
selected=$((echo && list_sinks "$selected_names_regex") | fzf --layout=reverse)
if [ -z "$selected" ]; then
break
fi
selected_names_regex="$selected_names_regex|$selected"
selected_names="$selected_names,$selected"
done
if [ ! -z "$selected_names" ]; then
pactl load-module module-combine-sink sink_name='combined' slaves="$selected_names"
pactl set-default-sink 'combined'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment