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:

[simterm]

$ sudo pacman -S bluez bluez-utils

[/simterm]

Check kernel’s module:

[simterm]

$ 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

[/simterm]

If it’s not found – load it:

[simterm]

$ sudo modprobe btusb

[/simterm]

Start the service:

[simterm]

$ systemctl start bluetooth.service
$ systemctl enable bluetooth.service

[/simterm]

bluetoothctl Linux

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

[simterm]

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

[/simterm]

Check for available commands with help:

[simterm]

[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
...

[/simterm]

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

[simterm]

[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

[/simterm]

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

[simterm]

[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

[/simterm]

Register the headset:

[simterm]

[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

[/simterm]

Connect it:

[simterm]

[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]#

[/simterm]

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:

[simterm]

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

[/simterm]

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:

[simterm]

$ sudo pacman -S blueman

[/simterm]

Run the applet:

[simterm]

$ blueman-applet

[/simterm]

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.