How-to use bluetooth in an AppVM

Kind of had a hard time getting bluetooth running despite there being quite a bunch of guides and problem-reports on the internetz. Or maybe because of that. As usual I found the arch wiki most helpful.

There is a guide for debian qubes somewhere which was helpful, but I wanted to use pipewire and debian being the old aunt…

Anyway, I’d like to share my writeup, since that might be useful for others.

### in dom0
# check and/or enable bluetooth controller
cat /sys/devices/platform/thinkpad_acpi/bluetooth_enable
echo 1 > /sys/devices/platform/thinkpad_acpi/bluetooth_enable

# you can try to persistently attach the bluetooth controller
# but the device ID (check which) might change after a reboot 
qvm-device usb attach --persistent podcasts sys-usb:1-7
### in templateVM
# archlinux, obviously
sudo pacman -S bluez bluez-tools bluez-utils blueman
sudo pacman -S pavucontrol pulseaudio-bluetooth linux-firmware
sudo pacman -S obs-studio

# enable experimental features for bluetooth
sudo nano /etc/bluetooth/main.conf
# put the following just under [General]
 FastConnectable = true
 Experimental = true
 KernelExperimental = true
### in appVM
# to be done once if you want to make bluetooth configs persistant
sudo cp /etc/bluetooth /rw/config/
sudo /bin/sh -c 'echo "mount --bind /rw/config/bluetooth /etc/bluetooth" >> /rw/config/rc.local'
sudo /bin/sh -c 'echo "mount --bind /rw/config/bluetooth /var/lib/bluetooth" >> /rw/config/rc.local'

# to be done after each reboot (after attaching the usb-bluetooth-controller)
rfkill list
sudo systemctl start bluetooth
pulseaudio -k ; pulseaudio -D

# play around with stuff
blueman-manager&
pavucontrol&
quake2&

I couldn’t get pipewire to work, though. Which is unfortunate as modern bluetooth headsets rely on modern codecs. To use a recent kernel in your archlinux qubes this is how-to it.

I’m happy for anybody correcting mistakes in my writeup… and for relevant advice concerning pipewire of course. I assume the qubes devs are working on it.

PS: this looks promising.

2 Likes

I’ve been trying to get bluetooth input working, as posted here. Reading your post, I thought the problem might be enabling the experimental features and installing firmware-linux on Debian but doesn’t help. The problem might be that some sort of signal that the bluetooth device sends when it is ready to record isn’t being received. Pavucontrol sees everything and switching to HSP/HFP does work correctly from what I can tell. I’ve been testing with gnome-audio-recorder and what I am seeing is that when you press record it takes you to the screen you see normally but the time is stuck at zero. Perhaps this can be solved by redirecting audio sinks as seen here, but I don’t know what to connect to what. It would be great if I could make this work but it’s looking like I’m going to have to buy a bluetooth to audio jack adapter :pensive:.

Apparently from this pulseaudio just doesn’t support HFP, so I should be looking into how to make pipewire work.

EDIT: Nevermind, this doesn’t seem to be the problem as my headphones support both HSP and HFP

I solved the problem I was having with bluetooth. Maybe my solution (missing firmware file) will help you too.

1 Like

Glad you solved the problem. In arch linux the package “linux-firmware” contains the hardware driver for my bluetooth hardware.

apt search --names-only ^firmware

might help you to locate the drivers you need as part of your distro, so you don’t have to rely on untrusted 3rd-party sources.

Meanwhile, I got pipewire to work and profit from the bluetooth codecs pipewire provides. Basically everthing one has to do is described in the Arch Wiki. They often do not explain in detail and keep things consise, but I almost always get my stuff working with the Arch Wikis help.

For pipewire support I used the following:

# remove pulseaudio (forcefully)
sudo pacman -Rdd pulseaudio pulseaudio-alsa pulseaudio-bluetooth

# install pipewire
sudo pacman -S pipewire pipewire-alsa pipewire-audio pipewire-pulse wireplumber       
sudo cp -r /usr/share/pipewire /etc/ 

# install bluetooth tools, pavucontrol, obs-studio
sudo pacman -S bluez bluez-tools bluez-utils blueman
sudo pacman -S pavucontrol linux-firmware
sudo pacman -S obs-studio

# there ought to be something like "qubes-vm-pipewire" (instead of "qubes-vm-pulseaudio")
# not necessary if we want to keep everything inside the VM (as the bluetooth-headset)
# pacman -S qubes-vm-pipewire <- maybe in Qubes 4.2-repositories