This guide is only for original Ubuntu out-of-the-box packages. If you have added a custom PPA like
pipewire-debian
, you might get into conflicts.
Ubuntu 22.04 has PipeWire partially installed and enabled as it's used by browsers (WebRTC) for recoding the screeen under Wayland. We can enable remaining parts and use PipeWire for audio and Bluetooth instead of PulseAudio.
Starting from WirePlumber version 0.4.8 automatic Bluetooth profile switching (e.g. switching from A2DP to HSP/HFP when an application needs microphone access) is supported. Jammy (22.04) repos provide exactly version 0.4.8. So, we're good.
Based on Debian Wiki, but simplified for Ubuntu 22.04.
Install Bluetooth codecs AAC/LDAC/AptX:
$ sudo apt install \
libfdk-aac2 \
libldacbt-{abr,enc}2 \
libopenaptx0
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
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/
Everything was done automatically by pipewire-pulse
package, which should have been installed by wireplumber
package as recommended. If not, install it yourself.
Just remove this package and Bluetooth will be handled by PipeWire:
$ sudo apt remove pulseaudio-module-bluetooth
Reboot and check if it works by running:
$ LANG=C pactl info | grep '^Server Name'
You may want to add your favorite recording/conferencing applications into WirePlumber policy settings so that WirePlumber can switch automatically when those applications start using microphone. Let's say you want to add Telegram application into that list. Add "Telegram Desktop"
and "telegram-desktop"
to the "media-role.applications"
section of the file /usr/share/wireplumber/policy.lua.d/10-default-policy.lua
so that it looks like this:
...
-- Application names correspond to application.name in stream properties.
-- Applications which do not set media.role but which should be considered
-- for role based profile switching can be specified here.
["media-role.applications"] = { "Chromium input", "Firefox", "Google Chrome input", "ZOOM VoiceEngine", "Microsoft Edge input", "Sound Recorder", "Telegram Desktop", "telegram-desktop" },
...
If you want to find name of your application to add it into the above list, you need to first open that application and put it into microphone on mode and then execute the following command:
$ pactl list | grep "application.name"
application.name = "Chromium"
module-stream-restore.id = "sink-input-by-application-name:Chromium"
application.name = "Telegram Desktop"
module-stream-restore.id = "sink-input-by-application-name:Telegram Desktop"
application.name = "Telegram Desktop"
module-stream-restore.id = "source-output-by-application-name:Telegram Desktop"
Here you we will see the different application names and ones that matches or comes close to your application, you can add it into the list explained above. For example "Telegram Desktop" is in my case.