Score:4

How to get bluetooth headset to default to HFP Profile and mSBC codec on Ubuntu 22.04

cn flag

Currently, whenever I reconnect my Bluetooth headset to Ubuntu 22.04, it defaults to the A2DP Sink profile. I then use pavucontrol to manually switch to HFP every time. How do I get this to stick so I don't have to keep changing it?

I've tried the solutions in Change Bluetooth Headphones default audio mode (A2DP Sink vs HSP/HFP) and none seem to work.

Score:2
in flag

I had a similar issue. My headset supports only audio with A2DP and needs to switch to HFP in order for my mic to work.

I switched from pulse audio to pipewire. "Pipewire (WirePlumber >= 0.4.8) [...] supports automatic Bluetooth profile switching (e.g. switching from A2DP to HSP/HFP when an application needs microphone access)."

This was a great solution for my use case. My laptop no longer uses the internal mic when joining MS Teams calls but automatically switches to my headset with HFP.

I am also running Ubuntu 22.04 and installed Pipewire manually.

Install

Install codecs for LDAC (SBC is included out of the box):

$ sudo apt install libldacbt-{abr,enc}2

Install remaining PipeWire packages and WirePlumber as the session manager:

$ sudo apt install \ libspa-0.2-bluetooth \
pipewire-audio-client-libraries \ pipewire-media-session- \
wireplumber

Notice '-' at the end of 'pipewire-media-session'. This is to remove it in the same command, because 'wireplumber' will be used

instead.

Start WirePlumber for your user:

$ systemctl --user --now enable wireplumber.service

Configure ALSA

Single step. Copy the config file from the PipeWire examples into your ALSA configuration directory:

$ sudo cp /usr/share/doc/pipewire/examples/alsa.conf.d/99-pipewire-default.conf /etc/alsa/conf.d/

PulseAudio

Everything was done automatically by pipewire-pulse package, which should have been installed by wireplumber package as recommended. If not, install it yourself. Bluetooth

Just remove this package and Bluetooth will be handled by PipeWire:

$ sudo apt remove pulseaudio-module-bluetooth

Done

Reboot and check if it works by running:

$ LANG=C pactl info | grep '^Server Name'

This is only a workaround and doesn't answer your question directly.

Score:1
io flag

Have the same problem. A simple command-line-workaround is to set the sink manually after the connect:

Set an alias in your ".profile" or ".bashrc" and simply use "hs" on the command-line after bluetooth-connect

alias hs='pacmd set-card-profile bluez_card.your_device handsfree_head_unit'

You can find your device with:

pacmd list

And the name will be something like this:

name: <bluez_card.AB_CD_EF_12_34_56>

After your Bluetooth headset is connected do:

hs

You can add a headphones setting easily too. For example:

    alias hp='pacmd set-card-profile bluez_card.your_device a2dp_sink'

I'm still looking for an automatic solution, too.

kennyB avatar
cn flag
Thank you for this - this is a helpful answer so I have upvoted it. It doesn't answer the question so I haven't accepted it yet. Please answer again (i.e. don't edit this) if you come up with an automatic solution. For me, I actually want to be able to easily switch as I also listen to music, so your solution is perfect for that.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.