1

I have a system with two audio cards: a scarlett 2i2 where I have connected two speakers and the HDMI monitor, where I have connected the headphones. Its also possible I connect at some point some bluetooth headphones.

I have created a null sink where I connect all the audio applications and I would like to automatically connect this null sink to my hardware audio devices. Since the bluetooth headphones may be present or not in the system, I guess I need to do this dynamically, so I need Wireplumber, but I have no idea how to do it.

I have added the my Pipewire graph. In blue, the applications playing some audio, connected to easy effects input. In red, the easy effects pipe, connected to my output null sink. In white, the hardware audio devices. These are getting audio from the null sink. These are the connections I want to generate automatically, as right now I have to connect them by hand when I boot the computer In yellow, the microphone pipeline.

enter image description here

How should I perform the connections from the null sink to the hardware devices automatically?

1 Answer 1

0

I ended up adding another answer since I did not really manage to accomplish anything with LUA scripts and pipewire conf... none the less... I managed to make it work... under ~/.config/systemd/user:

  1. Add custom.target file <<
[Unit]
Description=Custom Target
Requires=default.target
After=default.target
AllowIsolate=yes
  1. Add custom.service <<
[Unit]
Description=Custom Service
After=default.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/script #(i did ln -s, don't know about /path/to/script)
[Install]
WantedBy=custom.target
  1. Run systemctl --user set-default custom.target (should create a sim-link inside of the .config/systemd/user/default.target pointing to custom.target) *you should run systemctl --user get-default just to verify default.target is set...

  2. Run systemctl --user enable custom.service should create a sim-link to custom.target.wants

[EDIT] I'm posting my shell script, to better illustrate the process

#!/bin/sh

#Static Names
APPLDUALSINK=sink.Dual_Apple_Inc._Display_Audio.analog-stereo
APPLDUAL_L=alsa_output.usb-Apple_Inc._Display_Audio_27711502-00.analog-stereo
APPLDUAL_R=alsa_output.usb-Apple_Inc._Display_Audio_27711702-00.analog-stereo

function __link () {
        #link monitor left to playback left
        /usr/bin/pw-link $APPLDUALSINK:monitor_FL $APPLDUAL_L:playback_FL
        #link monitor left to playback right
        /usr/bin/pw-link $APPLDUALSINK:monitor_FL $APPLDUAL_L:playback_FR
        #link monitor right to playback left
        /usr/bin/pw-link $APPLDUALSINK:monitor_FR $APPLDUAL_R:playback_FL
        #link monitor right to playback right
        /usr/bin/pw-link $APPLDUALSINK:monitor_FR $APPLDUAL_R:playback_FR
}

#wait for pipewire sink
sleep 5

__link
1
  • This is useful and I already thought about using systemd to automate this. The issue is that the script is run once, and if by some reason a link is disconnected (in my case, they get disconnected when the displays enter sleep mode), the systemd script doesn't connects them again. Ideally, this should be done using wireplumber or pipewire-media-session
    – jjcasmar
    Dec 6, 2022 at 13:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .