Fix the "A2DP missing" Bluetooth issue on Linux (PipeWire/BlueZ) + one-key toggle between A2DP and HFP
https://github.com/karangandhi-projects/bluetooth-audio-manager-linux/blob/main/docs/demo-fast.mp4
On Linux (Ubuntu with PipeWire), Bluetooth earbuds/headphones may:
- Connect in Handsfree (HFP/HSP) instead of A2DP
- Lose the A2DP profile completely after reconnect
- Produce low-quality / distorted audio
- Require restarting Bluetooth to fix:
sudo systemctl restart bluetoothBluetooth audio uses two main profiles:
| Profile | Purpose | Quality | Mic |
|---|---|---|---|
| A2DP | Music playback | High | ❌ |
| HFP/HSP | Calls | Low | ✅ |
Important:
If
a2dp-sinkis missing inpactl list cards, it cannot be selected later — it must be recreated.
On reconnect, Linux Bluetooth stack (BlueZ + PipeWire):
- Negotiates available profiles
- Sometimes exposes only HFP
- Skips A2DP entirely
- System gets stuck in low-quality mode
👉 This is a negotiation issue, not just a settings problem.
pactl set-card-profile <card> a2dp-sinkbluetooth.autoswitch-to-headset-profile = falsesudo systemctl restart bluetoothThis project provides a Bluetooth Manager script that:
- Detects missing A2DP
- Restarts Bluetooth
- Reconnects device
- Restores A2DP
- Toggles between A2DP and HFP
git clone https://github.com/karangandhi-ptojects/bluetooth-audio-manager-linux.git
cd bluetooth-audio-manager-linux
chmod +x setup/install.sh
./setup/install.shexport BT_DEVICE_MAC="AA:BB:CC:DD:EE:FF"Find your device:
bluetoothctl devices- Detects current profile
- Toggles between A2DP and HFP
If A2DP is missing:
- Restart Bluetooth
- Reconnect device
- Restore profiles
- Switch to A2DP
- Bluetooth stack on Linux is not perfect
- Script mitigates, not eliminates root issue
Give it a star — it helps others find it.