How to Smoothly Connect to Bluetooth Devices in Arch Linux
I use Arch Linux to play games at home on weekends, and I need to connect to an Airpdos Pro or Bluetooth speaker. Over time, I've accumulated some experience, and I'd like to share it.
Mature desktop environments like KDE and Gnome all have GUI programs for Bluetooth connection. However, in some cases, problems may occur, and you'll still need to return to the command line interface to handle them. I've previously written about how to fix Bluetooth headset connection problems in Ubuntu.
This article focuses on how to ensure consistent connection to Bluetooth devices in a custom environment with Arch + labwc.
1. How to Connect a Bluetooth Device
I recommend going all in one go and using the bluetoothctl command-line tool. It's a practical solution for connecting to Bluetooth devices in Linux.
First, install the bluez package in Arch. This package provides the Bluetooth protocol stack, while the bluez-utils package provides the bluetoothctl command-line tool. Other distributions have similar options; a simple search will reveal them.
Bluetooth control mode issues:
1โ ~ grep ControllerMode -B3 /etc/bluetooth/main.conf
2# Restricts all controllers to the specified transport. Default value
3# is "dual", i.e., both BR/EDR and LE enabled (when supported by the hardware).
4# Possible values: "dual", "bredr", "le"
5#ControllerMode = dual
These are bidirectional, traditional, and low-power modes, respectively. I asked the AI ๐. If your device is newer, the default dual setting is fine. If that doesn't work, try changing to a different mode. A reboot is required for the configuration changes to take effect.
As shown in the output above, I'm using the default setting. I actually connect to both an AirPod Pro 2 and an Aciton III without any issues.
Using the Action III as an example (I've written about AirPods before), the demonstration process is as follows. First, after the speaker is powered on, press and hold the Bluetooth pairing button. When you hear the beep:
1โ ~ bluetoothctl
2[bluetooth]# Agent registered
3[bluetooth]# scan on
4[bluetooth]# SetDiscoveryFilter success
5[bluetooth]# Discovery started
6[bluetooth]# [CHG] Controller E4:C7:67:3F:6A:0A Discovering: yes
7[bluetooth]# [NEW] Device 77:FF:F0:47:08:D4 77-FF-F0-47-08-D4
8[bluetooth]# [NEW] Device C8:C2:E6:CC:9B:54 ACTON III [LE]
9[bluetooth]# [NEW] Device 7D:97:57:B3:41:3F 7D-97-57-B3-41-3F
10[bluetooth]# [NEW] Device 4B:40:4A:38:4F:92 4B-40-4A-38-4F-92
11[bluetooth]# [NEW] Device 50:5E:5C:95:0B:A4 ACTON III
12[bluetooth]# [NEW] Device 7A:02:E0:F1:DB:F6 7A-02-E0-F1-DB-F6
13[bluetooth]# connect [CHG] Device 7D:97:57:B3:41:3F RSSI: 0xffffffa4 (-92)
14[bluetooth]# connect 50:5E:5C:95:0B:A4
15Attempting to connect to 50:5E:5C:95:0B:A4
16[bluetooth]# [CHG] Device 7A:02:E0:F1:DB:F6 RSSI: 0xffffffa2 (-94)
17[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 Connected: yes
18[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 Modalias: bluetooth:v0094p0004d0100
19[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 UUIDs: 00000000-0000-0000-0099-aabbccddeeff
20[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 UUIDs: 00000000-deca-fade-deca-deafdecacaff
21[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
22[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
23[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
24[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
25[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 UUIDs: 0000ff01-0000-1000-8000-00805f9b34ff
26[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 UUIDs: df21fe2c-2515-4fdb-8886-f12c4d67927c
27[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 UUIDs: fa349b5f-8050-0030-0010-00001bbb231d
28[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 ServicesResolved: yes
29[ACTON III]# [NEW] Device F9:83:83:EA:E2:D6 F9-83-83-EA-E2-D6
30[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 Bonded: yes
31[ACTON III]# [CHG] Device 50:5E:5C:95:0B:A4 Paired: yes
32[ACTON III]# [NEW] Endpoint /org/bluez/hci0/dev_50_5E_5C_95_0B_A4/sep1
33[ACTON III]# [NEW] Transport /org/bluez/hci0/dev_50_5E_5C_95_0B_A4/sep1/fd0
34[ACTON III]# [CHG] Transport /org/bluez/hci0/dev_50_5E_5C_95_0B_A4/sep1/fd0 Delay: 0x05dc (1500)
35[ACTON III]# Connection successful
36[ACTON III]# [CHG] Transport /org/bluez/hci0/dev_50_5E_5C_95_0B_A4/sep1/fd0 Volume: 0x0013 (19)
37[ACTON III]# [NEW] Device 72:FF:AE:FE:20:06 72-FF-AE-FE-20-06
38[ACTON III]#
Look carefully at the output above, first scan on
Scanning for Bluetooth devices, [bluetooth]# [NEW] Device 50:5E:5C:95:0B:A4 ACTON III
indicates the MAC address has been correctly detected.
Naturally, [bluetooth]# connect 50:5E:5C:95:0B:A4
, and the subsequent output indicates a successful connection.
In addition, there are commands like pair xxx, trust xxx, disconnet xxx, and remove xxx. xxx represents the MAC address, and its meaning is easy to guess from the English meaning. It's also quite memorable, so just choose the one you need.
In most cases, after successfully connecting using the above connection methods, you can use the Bluetooth device normally (hearing sound and adjusting the volume). These are the only external Bluetooth devices I have, and I rarely encounter any problems.
As for the AirPods Pro 2, expecting them to be easily usable in various transparency and sound isolation modes is probably overkill. I only use them for gaming and primarily use them on iOS devices. When playing CS2, my allies said they made a strange electronic trembling sound when they spoke, but I couldn't hear it myself, so I didn't get the chance to experience it. ๐
2. What to do if you encounter problems
Step 1 above only covers a normal connection. What if you encounter a problem? My current solutions are listed below:
- What if the sound suddenly stops while connected?
At this time, the Bluetooth display is still connected, but there is no sound, or the sound is intermittent. This problem does occur with AirPods Pro2 (I don't encounter it with Action III, which is one of the reasons I bought this speaker). I don't know if it's because the Bluetooth module in my mini host is overheating, or some other strange reason.
I usually restart and reconnect. After buying a standalone speaker, I haven't used AirPods Pro2 to connect to a computer to play games. Playing with headphones is uncomfortable, and the battery is also limited.
After restarting, go through the connection process again and you can directly connect your_mac_address
. At least AirPods can do it. ```
sudo systemctl restart bluetooth.service
1- What to do if there's still no sound after rebooting?
2
3This question is crucial and the core motivation for writing this article. I figured it out after more than ten days of self-exploration. I can't believe I've found any relevant information on the entire Chinese internet. I'm not exaggerating.
4
5Before I bought the speakers, I had always used AirPdds to connect to my computer to listen to audio. I don't know when, after a rolling upgrade called `sudo pacman -Syu`, the whole setup stopped working, meaning I couldn't hear any sound from my computer.
6
7The consequences were severe. I couldn't hear any sound while gaming, and it was a long-term frustration. I thought the mini console's Bluetooth was broken. Double 11 was approaching, so I bought a speaker to try it out (also because I wanted to listen to music out loud, and the speakers were decent quality).
8
9Before the speakers arrived, I struggled with this issue. I tried everything, but couldn't hear any sound. Until one day, I noticed that my AirPods Pro 2 wasn't the default selection in the Sinks list (the asterisk in front of the device indicates it's selected, the current sound output device, and this situation can no longer be reproduced).
10
11Could this be the problem? I have good reason to doubt it. It used to work fine. I took a peek at it when I was there.
12
13```shell
14โ ~ wpctl status
15PipeWire 'pipewire-0' [1.2.6, mephisto@minipc, cookie:3413408580]
16โโClients:
1732. WirePlumber [1.2.6, mephisto@minipc, pid:779]
1833. pipewire [1.2.6, mephisto@minipc, pid:780]
1946. WirePlumber [export] [1.2.6, mephisto@minipc, pid:779]
2081. xdg-desktop-portal [1.2.6, mephisto@minipc, pid:953]
2182. waybar [1.2.6, mephisto@minipc, pid:900]
2283. wpctl [1.2.6, mephisto@minipc, pid:4354]
23
24Audio
25โโ Devices:
26โ 47. Rembrandt Radeon High Definition Audio Controller [alsa]
27โ 48. Family 17h/19h HD Audio Controller [alsa]
28โ
29โโ Sinks:
30โ 52. Rembrandt Radeon High Definition Audio Controller HDMI / DisplayPort 4 Output [vol: 1.00]
31โ 53. Rembrandt Radeon High Definition Audio Controller HDMI / DisplayPort 3 Output [vol: 1.00]
32โ 54. Rembrandt Radeon High Definition Audio Controller HDMI / DisplayPort 2 Output [vol: 0.70]
33โ 55. Rembrandt Radeon High Definition Audio Controller HDMI / DisplayPort 1 Output [vol: 1.00]
34โ * 56. Family 17h/19h HD Audio Controller Line Output [vol: 0.50]
35โ
36โโ Sources:
37โ 57. Family 17h/19h HD Audio Controller Front Stereo Microphone [vol: 1.00]
38โ * 58. Family 17h/19h HD Audio Controller Digital Microphone [vol: 0.49]
39โ
40โโ Filters:
41โ
42โโ Streams:
43
44Video
45โโ Devices:
46โ
47โโ Sinks:
48โ
49โโ Sources:
50โ
51โโ Filters:
52โ
53โโ Streams:
54
55Settings
56โโ Default Configured Devices:
570.Audio/Sink bluez_output.50_5E_5C_95_0B_A4.1
This little detail really saved me. It's probably the ultimate joy and sorrow for Linux users.
After finding the clue, the problem was quickly solved.
1pactl set-default-sink bluez_output.C0_95_6D_C0_A3_92.1
If you encounter a similar problem, the command above can be a lifesaver. It simply sets your default output device. It's ridiculous that Linux can't intelligently determine which device to use for output!
After setting both headphones and speakers as the default output devices, I no longer had the problem of no sound.
Will there be any problems if both are set as the default output? No, a normal person will only use one device to listen to sound at a time, and there won't be any conflict, unless someone has a specific use case.
If you don't understand what sinks and sources mean above, you can ask the AI. That's how I did it, and it works.
Another question: How did you get the address bluez_output.C0_95_6D_C0_A3_92.1
? Please see the following steps.
1โ ~ wpctl status
2PipeWire 'pipewire-0' [1.2.6, mephisto@minipc, cookie:3413408580]
3โโClients:
432. WirePlumber [1.2.6, mephisto@minipc, pid:779]
533. pipewire [1.2.6, mephisto@minipc, pid:780]
646. WirePlumber [export] [1.2.6, mephisto@minipc, pid:779]
781. xdg-desktop-portal [1.2.6, mephisto@minipc, pid:953]
882. waybar [1.2.6, mephisto@minipc, pid:900]
989. wpctl [1.2.6, mephisto@minipc, pid:4651]
10
11Audio
12โโ Devices:
13โ 47. Rembrandt Radeon High Definition Audio Controller [alsa]
14โ 48. Family 17h/19h HD Audio Controller [alsa]
15โ 83. ACTON III [bluez5]
16โ
17โโ Sinks:
18โ 52. Rembrandt Radeon High Definition Audio Controller HDMI / DisplayPort 4 Output [vol: 1.00]
19โ 53. Rembrandt Radeon High Definition Audio Controller HDMI / DisplayPort 3 Output [vol: 1.00]
20โ 54. Rembrandt Radeon High Definition Audio Controller HDMI / DisplayPort 2 Output [vol: 0.70]
21โ 55. Rembrandt Radeon High Definition Audio Controller HDMI / DisplayPort 1 Output [vol: 1.00] โ 56. Family 17h/19h HD Audio Controller Line Output [vol: 0.50]
22โ * 84. ACTON III [vol: 0.15]
23โ
24โโ Sources:
25โ 57. Family 17h/19h HD Audio Controller Front Stereo Microphone [vol: 1.00]
26โ * 58. Family 17h/19h HD Audio Controller Digital Microphone [vol: 0.49]
27โ
28โโ Filters:
29โ
30โโ Streams:
31
32Video
33โโ Devices:
34โ
35โโ Sinks:
36โ
37โโ Sources:
38โ
39โโ Filters:
40โ
41โโ Streams:
42
43Settings
44โโ Default Configured Devices:
450. Audio/Sink bluez_output.50_5E_5C_95_0B_A4.1
46โ ~ wpctl inspect 84
47id 84, type PipeWire:Interface:Node
48api.bluez5.address = "50:5E:5C:95:0B:A4"
49api.bluez5.codec = "sbc"
50api.bluez5.profile = "a2dp-sink"
51api.bluez5.transport = ""
52bluez5.loopback = "false"
53card.profile.device = "1"
54* client.id = "46"
55clock.quantum-limit = "8192"
56device.api = "bluez5"
57* device.id = "83"
58device.routes = "1"
59* factory.id = "12"
60factory.name = "api.bluez5.a2dp.sink"
61library.name = "audioconvert/libspa-audioconvert"
62* media.class = "Audio/Sink"
63media.name = "ACTON III"
64* node.description = "ACTON III"
65node.driver = "true"
66node.loop.name = "data-loop.0"
67* node.name = "bluez_output.50_5E_5C_95_0B_A4.1"
68node.pause-on-idle = "false"
69* object.serial = "97"
70port.group = "stream.0"
71* priority.driver = "1010"
72* priority.session = "1010"
73session.suspend-timeout-seconds = "0"
From wpctl inspect 84
node.name = "bluez_output.50_5E_5C_95_0B_A4.1"
, 84 is sinks The device ID changes dynamically, while node.name generally remains unchanged.
Look carefully at the end of the output above. You'll see a line labeled Default Configured Devices
, indicating that the configuration was successful.
What is wpctl? It's the WirePlumber command-line tool.
What is WirePlumber? WirePlumber is a session manager for managing audio and video streams in Linux systems. It replaces the previous PulseAudio session manager and primarily handles multimedia stream routing and policies, somewhat similar to the concept of a gateway in an internet enterprise.
Current Linux all use PireWire, a low-level multimedia framework for handling audio and video on Linux systems. PipeWire was developed to replace PulseAudio, with features including support for audio output in containerized applications and for professional audio scenarios. Simply put, the two work together, so it's normal for both to have "wire" in their names.
- After all the above troubleshooting, what should I do if I still can't hear any sound?
Generally speaking, this rarely happens. If it does, make sure the device is connected and the correct device is selected in the sinks.
In the bluetoothctl
command line, disconnect xxx, then remove xxx, then restart the Bluetooth service and reconnect. (Action III has a similar mechanism; if it's not used for a long time, it will disconnect; reconnecting will fix it.)
Finally, isn't your time free for all this trouble? I'm broke, so my time is basically worthless. I can learn something ๐ . I'm a pioneer in laying down mines, so others don't have to take the brunt of the damage! Someone actually wrote me an email to thank me. Someone's always the first to try it, and it really does solve the problem of no sound when playing games.
Why don't you use Windows for gaming? I don't like Windows. I prefer the command line. Aside from the kernel, the entire system environment is completely customized, just like how many people enjoy modifying cars; they're most comfortable with tools they build themselves.
Copyright statement:
- All content that is not sourced is original., please do not reprint without authorization (because the typesetting is often disordered after reprinting, the content is uncontrollable, and cannot be continuously updated, etc.);
- For non-profit purposes, to deduce any content of this blog, please give the relevant webpage address of this site in the form of 'source of original text' or 'reference link' (for the convenience of readers).
See Also:
- Gif screen recording in Wayland environment
- Install the latest version of Python for Linux
- Ubuntu 22.10 connection bluetooth headset error 'br-connection-profile-unavailable solution'
- Ubuntu connects AirPods headphones
- alacritty terminal use
- Mini console assembly notes
- Greetd and greetd tutorial
- My Toolbox
- A Brief Introduction to Scientific Internet Access with Xray
- Manage Configuration Files with Git and Ansible