Auto switch to A2DP bluetooth device when connected in Ubuntu

Add to /etc/pulse/default.pa to automatically switch pulseaudio sink to Bluez:

 .ifexists module-bluetooth-discover.so
 load-module module-bluetooth-discover
 load-module module-switch-on-connect  # Add this
 .endif

Modify /etc/bluetooth/audio.conf to auto select A2DP profile (instead of HSP/HFP):

 [General]
 Disable=Headset # Add this

Apply changes:

sudo pulseaudio -k # Restarts pulseaudio
sudo restart --system bluetooth # Restarts BT
Tagged , , , . Bookmark the permalink.

9 Responses to Auto switch to A2DP bluetooth device when connected in Ubuntu

  1. BlackPlaid says:

    I’ve been having intermittent trouble with auto connecting. Regardless, this works great for auto connecting in A2DP. It’s much easier to just manually connect BT than to have to also open audio settings, switch adapter, switch from hsp to A2DP.

    Is it possible to switch back to built in audio automatically on BT disconnect?

  2. Evren Yurtesen says:

    My headset just doesnt connect anymore without the headset service

  3. Paul says:

    Hello!

    There is a minor mistake. The pulseaudio process is owned by the current user, so `sudo` must be omitted:

    pulseaudio -k # no sudo

  4. Ubuntu User says:

    These instructions made it so that sound settings showed no output whatsoever. Before I had a choice between bluetooth device or headset- now nothing.

  5. PK says:

    This is awesome!!! Can’t belive it worked. It’s kind of sad that this functionality isn’t built in as a “preference” of some kind in gnome/unity tho…
    Also, in ubuntu 17.04 the bt configuration file is /etc/bluetooth/main.conf instead of /etc/bluetooth/audio.conf

  6. Kiran Baddi says:

    Brilliant. This worked so well.

  7. Rajesh Chaudhary says:

    Thank you very much. works well on Ubuntu 20.04

  8. Mohannad Hussain says:

    Thank you, this works great! One small deviation I’ve found on Ubuntu 20.04 is that default.pa is actually under:
    /var/lib/gdm3/.config/pulse/default.pa

Leave a Reply

Your email address will not be published. Required fields are marked *