Automatically switch sound output device to Bluetooth headset & force to A2DP profile on connection

Solution 1:

This worked for me: https://sandalov.org/blog/2146/

Instructions copied here for posterity:

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/Create /etc/bluetooth/audio.conf to auto select A2DP profile (instead of HSP/HFP):

[General]
Disable=Headset # Add this

Apply changes:

pulseaudio -k # Restarts pulseaudio

# You may need to turn your bluetooth headphones off, then back on

Solution 2:

It is not only after a reboot but also after disconnecting and reconnecting a device capable of both, HSP, and A2DP profile that Bluez always connects it in HSP (headest) mode.

I can't in detail tell what is going on under the hood (Bluetooth has quite some quirks) but I suspect that we are connecting a new device as Headset rather than as an Audio or AudioSink device via dbus.

There appears to be no setting by which we can control this. I am not aware of any settings we can make to default a Bluetooth device to A2DP on connecting (but I cannot exclude that I missed a piece of documentation somewhere). This may be considered a bug.

At some time I wrote a script to establish Bluetooth connections using the Audio profile. This script was included in a little GUI Python application (bt-autoconnect on launchpad or through my ppa:takkat-nebuk/takkat) which amongst other tweaks does exactly this but it is more of a hack than a definite solution, and sadly it does not work with all adapters around but it will connect my Philips headset in A2DP mode first (even though sound settings still claim it was HFP but that's another issue).