Make Bluetooth headset work properly in Ubuntu


Problem: missing BT headset mic in input devices. So I can use only my BT headphones with internal laptop mic.

Solution: switch to PipeWire.


Install PipeWire
$ sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream
$ sudo apt update
$ sudo apt install pipewire gstreamer1.0-pipewire libspa-0.2-bluetooth pipewire-audio-client-libraries

Reload the list of SystemD daemons:
$ systemctl --user daemon-reload

Disable Pulseaudio
$ systemctl --user --now disable pulseaudio.service pulseaudio.socket
$ systemctl --user mask pulseaudio

...and enable Pipewire
$ systemctl --user --now enable pipewire-media-session.service
$ systemctl --user restart pipewire-pulse.service

Check out
$ pactl info

Server Name should be smth like PulseAudio (on PipeWire 0.3.45)

Now you can switch between Headset Head Unit (HSP/HFP) and High Fidelity Playback (A2DP Sink) profiles.

For switching profiles quickly via terminal bind aliases:
alias sound_good="pactl set-card-profile $(pactl list cards |grep 'Name: bluez' |awk '{print $2}') a2dp-sink"
alias sound_talk="pactl set-card-profile $(pactl list cards |grep 'Name: bluez' |awk '{print $2}') headset-head-unit"

If you have audio delay when watching movies / playing games, install pavucontrol (PulseAudio Volume Control):
$ sudo apt install pavucontrol

...and change Latency offset in Output Devices -> Advanced.