Working Qubes Bluetooth Audio Notes

15 Oct 2020

I managed to get bluetooth audio on Qubes 4.0 working for one VM at a time.

These notes assume you have sys-usb set up. The below steps use a fedora 32 template VM however it should work generically on any fedora template VM. For other distributions the installed package names will be different.


Test in sys-usb

I recommend getting your device connected in sys-usb so you don't have to worry about whether the bluetooth controller (or usb) is available or not.

In the template VM to the sys-usb App VM install pulseaudio-module-bluetooth and bluez:

dnf install -y pulseaudio-module-bluetooth bluez

Restart sys-usb.

After sys-usb has been restarted, load the bluetooth discovery module on a sys-usb terminal:

pactl load-module module-bluetooth-discover

Start the bluetoothctl interface. Put your device in pairing mode and disconnect it or forget it from other devices that automatically connect to it. Scan for devices. Wait for your device address to show up on the bluetoothctl interface. Trust the device you want to connect to. Pair the device, and then connect to it:

sudo bluetoothctl
scan on
trust <your device address>
pair <your device address>
connect <your device address>

The device address should be output to the screen at some point after the scan on command has been run. See the example bluetoothctl output below for more information.

Your output and the device should indicate that it's connected. Run speaker-test in the command-line or copy over an audio file to sys-usb to confirm (warning: speaker-test is loud).


Test in desired VM

After you have bluetooth working in the sys-usb, you can try it in the VM that you actually want to use. Make sure the template VM has the aforementioned packages installed, the bluetooth module loaded (in the template for persistence?), and make sure the VM has been restarted since those steps.

Attach bluetooth controller

Attach your bluetooth controller (or bluetooth usb) to the working VM. Do this with the usb-attach widget. Mine is labeled as Broadcom_Corp_ followed by a long string of digits and numbers.

Afterward follow the same steps as in the sys-usb step.


Thoughts

I'm sure with more knowledge about pulseaudio once could network multiple VMs audio to a singular pulseaudio server which then could forward it to the bluetooth device.

If one wanted to integrate this audio how Qubes does audio, it would require connecting bluetooth devices to dom0 which may not be the best idea.


Example bluetoothctl output

user@self ~$ sudo bluetoothctl
Agent registered
[CHG] Controller 68:94:23:EF:B1:F7 Pairable: yes
[bluetooth]# scan on
Discovery started
[CHG] Controller 68:94:23:EF:B1:F7 Discovering: yes
[NEW] Device 50:17:09:02:17:6A MoKo-EP-S740
[bluetooth]# trust 50:17:09:02:17:6A
[CHG] Device 50:17:09:02:17:6A Trusted: yes
Changing 50:17:09:02:17:6A trust succeeded
[bluetooth]# pair 50:17:09:02:17:6A
Attempting to pair with 50:17:09:02:17:6A
[CHG] Device 50:17:09:02:17:6A Connected: yes
[CHG] Device 50:17:09:02:17:6A UUIDs: 00001108-0000-1000-8000-00805f9a44fb
[CHG] Device 50:17:09:02:17:6A UUIDs: 0000110b-0000-1000-8000-00805f9a44fb
[CHG] Device 50:17:09:02:17:6A UUIDs: 0000110c-0000-1000-8000-00805f9a44fb
[CHG] Device 50:17:09:02:17:6A UUIDs: 0000110e-0000-1000-8000-00805f9a44fb
[CHG] Device 50:17:09:02:17:6A UUIDs: 0000111e-0000-1000-8000-00805f9a44fb
[CHG] Device 50:17:09:02:17:6A ServicesResolved: yes
[CHG] Device 50:17:09:02:17:6A Paired: yes
Pairing successful
[CHG] Device 50:17:09:02:17:6A ServicesResolved: no
[CHG] Device 50:17:09:02:17:6A Connected: no
[bluetooth]# connect 50:17:09:02:17:6A
Attempting to connect to 50:17:09:02:17:6A
[CHG] Device 50:17:09:02:17:6A Connected: yes
Connection successful
[CHG] Device 50:17:09:02:17:6A ServicesResolved: yes
[MoKo-EP-S740]#

Reference

The archlinux wiki was by far the most helpful resource I found.

https://wiki.archlinux.org/index.php/Bluetooth_headset