Auto switch to bluetooth headphones

Help for Current Versions of MX
When asking for help, use Quick System Info from MX Tools. It will be properly formatted using the following steps.
1. Click on Quick System Info in MX Tools
2. Right click in your post and paste.
Message
Author
User avatar
kloos
Posts: 29
Joined: Tue Jun 02, 2020 10:25 am

Auto switch to bluetooth headphones

#1 Post by kloos »

Hi all,

A recent trip to another distro showed me that my Bluetooth headphones connected and were auto-selected.

Back in MX, which is so much better in many other ways... I have to manually select the headphones in the sound option every time I connect them. If I don't, the sound comes out of the laptop.

Is there a way to automate the switch in MX?

Thanks

User avatar
RallyDarkstrike
Posts: 151
Joined: Fri Jan 22, 2021 1:51 pm

Re: Auto switch to bluetooth headphones

#2 Post by RallyDarkstrike »

Seconding this as I only realized and found out about this last night....

Running Linux Mint MATE on my Lenovo Thinkpad T520, the second I connect my JVC Bluetooth headphones, the audio is happily transferred over automatically, but I was stumped for a second at first when I tried it on my HP Stream last night with the same headphones and the noise kept coming out of the speakers!
Image

User avatar
Eadwine Rose
Administrator
Posts: 14777
Joined: Wed Jul 12, 2006 2:10 am

Re: Auto switch to bluetooth headphones

#3 Post by Eadwine Rose »

Please share your full Quick System Info, found in the menu. Press the Copy for forum button, then click paste in a reply.. thanks.


Oh.. I thought a post by a new person was asking for help. *chuckles*
MX-23.6_x64 July 31 2023 * 6.1.0-37amd64 ext4 Xfce 4.20.0 * 8-core AMD Ryzen 7 2700
Asus TUF B450-Plus Gaming UEFI * Asus GTX 1050 Ti Nvidia 535.247.01 * 2x16Gb DDR4 2666 Kingston HyperX Predator
Samsung 870EVO * Samsung S24D330 & P2250 * HP Envy 5030

User avatar
mxUs3r
Posts: 4
Joined: Fri Mar 22, 2024 2:29 pm

Re: Auto switch to bluetooth headphones

#4 Post by mxUs3r »

Hi

I had the same problem and solved it with single command run in the terminal:

Code: Select all

pactl load-module module-switch-on-connect
and it worked like charm, but it was not persistent,
after reboot I needed to run the same command every time. I tried different solutions from forums around, but nothing worked.
I spend 5-6 hours and grabbing peaces from those forums - I solved it:

1. I created a shell script with that command above:

Code: Select all

#!/bin/sh

sleep 12s
pactl load-module module-switch-on-connect
exit 0
2. Saved it as "auto-switch-nk.sh" in "~/.config" folder (you can save it in your home folder if you want)
3. I used "Sessions and Startup" tool to create auto start entry:
4. On tab "Application Autostart" click "+Add" button
5. Fill the fields as below:

Name: auto-switch
Description: <put whatever you want here>
Command: - I clicked the folder icon along this field and indicated to that shell script above in ".config" folder
Trigger: on login

-- after reboot it did not work, then I:

4. opened the the file that "Sessions and Startup" created for me "nano ~/.config/autostart/auto-switch-nk.desktop"
5. Added "sh" right after "Exec=" on line 7. (if it's there in your case - just ignore this)
This is what the file "auto-switch-nk.desktop" looked like eventually:

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=auto-switch-nk
Comment=Auto switch to bluetooth headphones
Exec=sh /home/USER_NAME/.config/auto-switch-nk.sh
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false
!! Don't forget to replace "USER_NAME" with your actual username in the field above

After reboot - I have it working.

Hope this helps =)

User avatar
mxUs3r
Posts: 4
Joined: Fri Mar 22, 2024 2:29 pm

Re: Auto switch to bluetooth headphones

#5 Post by mxUs3r »

Ohh, I am sorry, My post is duplicated, I messed with "Preview and Submit" buttons.
Please just remove the top one, I guess the lower post is shorter and more understandable.
Thanks

User avatar
Eadwine Rose
Administrator
Posts: 14777
Joined: Wed Jul 12, 2006 2:10 am

Re: Auto switch to bluetooth headphones

#6 Post by Eadwine Rose »

Done. Hope I removed the one you intended to go :)
MX-23.6_x64 July 31 2023 * 6.1.0-37amd64 ext4 Xfce 4.20.0 * 8-core AMD Ryzen 7 2700
Asus TUF B450-Plus Gaming UEFI * Asus GTX 1050 Ti Nvidia 535.247.01 * 2x16Gb DDR4 2666 Kingston HyperX Predator
Samsung 870EVO * Samsung S24D330 & P2250 * HP Envy 5030

Charlie Brown

Re: Auto switch to bluetooth headphones

#7 Post by Charlie Brown »

There was even a request by @CharlesV for it to be "ootb":

viewtopic.php?t=78678

User avatar
mxUs3r
Posts: 4
Joined: Fri Mar 22, 2024 2:29 pm

Re: Auto switch to bluetooth headphones

#8 Post by mxUs3r »

Thanks
yes, you removed the one I intended.
I did not find that post (78678) to follow before I managed it my way =)

I've just looked into the file:

Code: Select all

/usr/share/pipewire/pipewire-pulse.conf
Or the guy miss spelled it or the config file changed since then.

I could not find any:

Code: Select all

content.exec:
in that file , but I think he means this part/block of the file:

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" }

Post Reply

Return to “MX Help”