Linux: connect Bluetooth headset with bluetoothctl and Blueman

By | 02/02/2021
 

Recently, I bought a Sony WH-1000XM3 headset.

In general, they are great but need to connect them to my laptop with Arch Linux.

The documentation about Bluetooth on Arch Linux can be found here>>> and here>>>:

Installation

Install necessary packages:

sudo pacman -S bluez bluez-utils

Check kernel’s module:

lsmod | grep btusb
btusb                  40960  0
btrtl                  16384  1 btusb
btbcm                  16384  1 btusb
btintel                16384  1 btusb
bluetooth             475136  5 btrtl,btintel,btbcm,btusb
usbcore               208896  12 usbnet,uvcvideo,usbhid,cdc_mbim,ehci_hcd,cdc_acm,cdc_ncm,cdc_wdm,xhci_pci,btusb,xhci_hcd,ehci_pci

If it’s not found – load it:

sudo modprobe btusb

Start the service:

systemctl start bluetooth.service
systemctl enable bluetooth.service

bluetoothctl Linux

Run Запускаем консоль управления Bluetooth CLI:

bluetoothctl
[NEW] Controller B8:76:3F:AB:D0:24 BlueZ 5.47 [default]
Agent registered
[bluetooth]#

Check for available commands with help:

[bluetooth]# help
Available commands:
list                       List available controllers
show [ctrl]                Controller information
select <ctrl>              Select default controller
devices                    List available devices
paired-devices             List paired devices
...

Start the Bluetooth controller on the laptop and run a bluetooth agent that will perform devices registration:

[bluetooth]# power on
[CHG] Controller B8:76:3F:AB:D0:24 Class: 0x0000010c
Changing power on succeeded
[CHG] Controller B8:76:3F:AB:D0:24 Powered: yes
[bluetooth]# agent on
Agent is already registered
[bluetooth]# default-agent
Default agent request successful

Power on the headset and search for available devices on your laptop:

[bluetooth]# scan on
Discovery started
[CHG] Controller 34:CF:F6:94:01:73 Discovering: yes
...
[NEW] Device 38:18:4C:BD:68:DE LE_WH-1000XM3

Register the headset:

[bluetooth]# pair 38:18:4C:BD:68:DE
Attempting to pair with 38:18:4C:BD:68:DE
[CHG] Device 38:18:4C:BD:68:DE Connected: yes
[CHG] Device 38:18:4C:BD:68:DE Name: WH-1000XM3
[CHG] Device 38:18:4C:BD:68:DE Alias: WH-1000XM3
...
[CHG] Device 38:18:4C:BD:68:DE Paired: yes
Pairing successful
[CHG] Device 38:18:4C:BD:68:DE ServicesResolved: no
[CHG] Device 38:18:4C:BD:68:DE Connected: no

Connect it:

[bluetooth]# connect 38:18:4C:BD:68:DE
Attempting to connect to 38:18:4C:BD:68:DE
[CHG] Device 38:18:4C:BD:68:DE Connected: yes
Connection successful
[CHG] Device 38:18:4C:BD:68:DE ServicesResolved: yes
[WH-1000XM3]#

And now the sound is going through them:

To make the headset to be paired automatically after powering them on – add them the trusted-devices:

[CHG] Device 38:18:4C:BD:68:DE Trusted: yes
Changing 38:18:4C:BD:68:DE trust succeeded

Blueman

There is a GUI-based package to add and configure Bluetooth devices, also it can place an icon to the systray – blueman, install it:

sudo pacman -S blueman

Run the applet:

blueman-applet

To start the applet automatically on the system’s startup – in Openbox you can add it  to the ~/.config/openbox/autostart file:

blueman-applet &

Done.