Page 2 of 4

Re: Request addition to pipewire config - auto switch

Posted: Tue Jan 02, 2024 9:43 pm
by AVLinux
dolphin_oracle wrote: Tue Jan 02, 2024 8:21 pm
FWIW, this affects all connected audio devices, not just bluetooth ones. its quit irritating when pluggin in a microphone to have all your audio switch to the mic, even the output. I'm going to guess that it might be similar for other types of connections, maybe even HDMI audio, although I haven't tested that.
Eeegads!

That gives me cold sweats in a Studio context... :confused:

Re: Request addition to pipewire config - auto switch

Posted: Tue Jan 02, 2024 10:57 pm
by CharlesV
dolphin_oracle wrote: Tue Jan 02, 2024 8:21 pm I need to think about it. I'm inclined to make a switch for it.

FWIW, this affects all connected audio devices, not just bluetooth ones. its quit irritating when pluggin in a microphone to have all your audio switch to the mic, even the output. I'm going to guess that it might be similar for other types of connections, maybe even HDMI audio, although I haven't tested that.

does work though.
Makes sense that it is setup to switch any audio device... but I think I would agree with you about making a switch for it.

The plus side is behaving like that it would be excellent for plugging in an hdmi, connecting a bluetooth speaker.. those seem very 'normal' to me ...

But at the risk of messing people up with other devices, like what your describing, or heavy audio connections... a switch to turn that feature off would be good.

Re: Request addition to pipewire config - auto switch

Posted: Tue Jan 02, 2024 11:03 pm
by CharlesV
Maybe we can learn something from how KDE does this?

I will fire up a KDE test machine tomorrow and see if I can find out how that happens. My understanding is that KDE auto switches to bluetooth when it connects but obviously xfce does not.

Re: Request addition to pipewire config - auto switch

Posted: Tue Jan 02, 2024 11:22 pm
by Stevo
I can confirm that MX 21 and 23 KDE do switch automatically, and if I connect yet another BT earphone or speaker on top of the existing, they switch to the new one. And switch back if that new device is disconnected.

I wonder if this has come up on the XFCE forums yet, or if another XFCE distro has addressed this annoyance.

Re: Request addition to pipewire config - auto switch

Posted: Wed Jan 03, 2024 10:06 am
by CharlesV
In my search before when mx23 was in beta stages, I found several places complaining about it, but only that link I posted had 'the fix' (and on the Arch website.)

In looking around this am I found a few more sites complaining about it, but not a lot and no mention of it on the xfce forum that I could find.

Re: Request addition to pipewire config - auto switch

Posted: Wed Jan 03, 2024 7:03 pm
by CharlesV
You all probably already know this, but I compared MX 23 KDE and XFCE pipewire configs (identical ) , yet the KDE version works perfectly switching to a connected bluetooth device.

I tried work through configs etc and I cannot see anything that is different that would do this. Yet... it does ;-/

Re: Request addition to pipewire config - auto switch

Posted: Wed Jan 03, 2024 7:19 pm
by dolphin_oracle
CharlesV wrote: Wed Jan 03, 2024 7:03 pm You all probably already know this, but I compared MX 23 KDE and XFCE pipewire configs (identical ) , yet the KDE version works perfectly switching to a connected bluetooth device.

I tried work through configs etc and I cannot see anything that is different that would do this. Yet... it does ;-/
unlike Xfce, KDE itself has a daemon that manages connections. gnome probably does too.

Re: Request addition to pipewire config - auto switch

Posted: Wed Jan 03, 2024 7:34 pm
by CharlesV
dolphin_oracle wrote: Wed Jan 03, 2024 7:19 pm
CharlesV wrote: Wed Jan 03, 2024 7:03 pm You all probably already know this, but I compared MX 23 KDE and XFCE pipewire configs (identical ) , yet the KDE version works perfectly switching to a connected bluetooth device.

I tried work through configs etc and I cannot see anything that is different that would do this. Yet... it does ;-/
unlike Xfce, KDE itself has a daemon that manages connections. gnome probably does too.
That would make sense.

Re: Request addition to pipewire config - auto switch

Posted: Sun Apr 07, 2024 8:59 am
by mxUs3r
Posting the updated version of the solution as in "/usr/share/pipewire/pipewire-pulse.conf" I was unable to find "content.exec" part, it could be the config file structure update or something, not sure.

I am referring to "by CharlesV ยป Tue Jan 02, 2024 5:13 pm" post here

including the point of the post/note above, your changes to survive the update, instead of edit the file "/usr/share/pipewire/pipewire-pulse.conf" - you just:

1. Create the folder "pipewire" (if does not exist) in "~/.config" folder of the current user:

Code: Select all

mkdir ~/.config/pipewire
2. copy "pipewire-pulse.conf" file from "/usr/share/pipewire" folder into "~/.config/pipewire" folder:

Code: Select all

sudo cp /usr/share/pipewire/pipewire-pulse.conf ~/.config/pipewire/
(you can copy all config files from there if you want)

3. Change ownership of the file:

Code: Select all

sudo chown USER:USER ~/.config/pipewire/pipewire-pulse.conf
(replace USER:USER with your actual username!)

4. Open the file in your favourite text editor:

Code: Select all

vim ~/.config/pipewire/pipewire-pulse.conf
5. Find the blocks

Code: Select all

context.exec =
and

Code: Select all

pulse.cmd =
(they are one on top of the other actually)

6. Add two lines of code to each block accordingly, to make like this:

Code: Select all

context.exec = [
    #{ path = "pactl"        args = "load-module module-always-sink" }
    #{ path = "pactl"        args = "upload-sample my-sample.wav my-sample" }
    #{ path = "/usr/bin/sh"  args = "~/.config/pipewire/default.pw" }
    { path = "pactl"         args = "load-module module-switch-on-connect" }
]
and

Code: Select all

pulse.cmd = [
    { cmd = "load-module" args = "module-always-sink" flags = [ ] }
    #{ cmd = "load-module" args = "module-switch-on-connect" }
    #{ cmd = "load-module" args = "module-gsettings" flags = [ nofail ] }
    { cmd = "load-module" args = "module-switch-on-connect" }
]
(Pay attention to those two last lines in each block)

7. Reboot and try, it works for me.

I posted different approach in my post (https://www.forum.mxlinux.org/viewtopic.php?t=73504), before I sorted the problem like this one.
you can check that post if you want, but I think this method is better way to solve it =)

Worth mentioning that if you want those changes system wide, if you have multiple users for example, then you can do these steps
into "/etc/pipewire" instead of "~/.config/pipewire"
(in that case ignore the step 3. as no ownership changes needed here).

Re: Request addition to pipewire config - auto switch

Posted: Sun Apr 07, 2024 11:11 am
by CharlesV
@mxUs3r Nicely done! I shall have to give this a try on my next build (or before maybe!)