The Bluetooth Audio Shuffle
Managing Bluetooth audio in Linux has historically been complex, though PulseAudio and its modern replacement, PipeWire, have made massive improvements. However, a persistent annoyance remains regarding audio profiles. When you connect a Bluetooth headset to Ubuntu, it can operate in two modes: A2DP (High Fidelity Playback) for listening to high-quality music, or HSP/HFP (Headset Head Unit) for two-way voice calls, which significantly degrades audio quality. By default, if Ubuntu detects any application trying to use a microphone—even if it’s just a web browser opening a page with an inactive webRTC element—it will automatically switch your headset profile from high-quality A2DP to low-quality HSP/HFP, ruining your music.
Locking the PulseAudio/PipeWire Profile
To prevent sudden drops in audio quality and stop Ubuntu from automatically switching your Bluetooth audio profiles to Headset mode when a microphone is polled, you must adjust the Bluetooth policy settings.
If you are on a newer Ubuntu release using WirePlumber (the session manager for PipeWire), you need to disable the “auto-switch” role. Open a terminal and create a local configuration override. Create the directory by running mkdir -p ~/.config/wireplumber/bluetooth.lua.d/. Next, create a new file: nano ~/.config/wireplumber/bluetooth.lua.d/51-bluez-autoswitch.lua. In this new file, paste the following exact line: bluez_monitor.properties["bluez5.roles"] = "[ a2dp_sink a2dp_source ]". Save (Ctrl+O) and exit (Ctrl+X). Finally, restart the audio service by running systemctl --user restart wireplumber. Your headset will now remain locked in high-fidelity A2DP mode, though you will need to manually switch it to HSP/HFP in the sound settings if you actually intend to use the headset’s built-in microphone for a call.