×

How to Setup Bluetooth on Arch Linux – LinuxWays

How to Setup Bluetooth on Arch Linux – LinuxWays


Wireless connectivity has now become very common these days as it is far more convenient than the traditional way of connecting peripherals or any output devices with the system. Most wireless devices use Bluetooth technology to connect with the computer as there is no range constraint. So every operating system and computer these days nearly comes with the option of Bluetooth connectivity.

Apart from connecting devices through Bluetooth, data can also be transferred but due to other fast data transfer technologies, its use for data transfers is drastically reduced. Arch Linux, like every other operating system, comes with the Bluetooth feature but to use it, it needs to be configured first.

Contents:

 

How To Setup Bluetooth on Arch Linux

There are two ways by which Bluetooth can be used on Arch Linux one is by using BlueZ which is a Bluetooth protocol stack and the second one is Bluemnan which is the Bluetooth manager for GTK GNOME. So, on Arch we can install both, in fact, BlueZ might be pre-installed on your system but still needs to be configured.

Step 1: Install BlueZ on Arch Linux

To configure Bluetooth on Arch Linux it is necessary to have Bluetooth manager installed on it however by default BlueZ is installed on Arch Linux, but you can confirm its installation by checking its version. If it is not installed, then you can install it using the Pacman package manager:

Step 2: Install BlueZ Utilities on Arch

Now to ensure the proper functioning of Bluetooth it is necessary to install the utilities for BlueZ as these utilities include, they include the bluetoothctl utility, which is a command-line interface for pairing, connecting, and disconnecting Bluetooth devices. You can also use bluez-utilities to enable and disable the Bluetooth service, scan for nearby devices, and transfer files via Bluetooth.

sudo pacman -S bluez-utils

If you have scripts or applications that depend on the deprecated BlueZ tools, or if you prefer to use them for some reason. Then you can install the bluez-utils-compat AUR package, which provides the deprecated BlueZ tools that are no longer included in the official bluez-utils package.

yay -S bluez-utils-compat

However, you should be aware that these tools will no longer be updated, and may not work properly with newer versions of BlueZ and you might get an error while installing them as in the image below:

So, in that case keep the bluez-utils as it is advisable to migrate to the bluetoothctl utility, which offers more features and stability for Bluetooth management.

Step 3: Enable btusb on Arch Linux

The btusb is a kernel module, which provides support for Bluetooth USB devices on Linux. This module is required to enable and configure Bluetooth devices on your system. So, first check if this kernel module is activated or not and for that execute:

Here the lsmod command is used to display the loaded kernel modules in Arch and if the output is empty as in the image below then you have to load this kernel module.

Now to load the btusb module on Arch Linux use the modprobe command that can add or remove modules from the Linux kernel:

Now as you can see the btusb module is now loaded.

Step 4: Enable Bluetooth Service

Now first check the status of the Bluetooth service and if it is inactive then first start it and after that enable it by using the systemctl utility:

sudo systemctl start bluetooth</strong>

<strong>sudo systemctl enable bluetooth

Step 5: Install Blueman Bluetooth Manager

Blueman is a graphical interface for managing and controlling Bluetooth devices on Arch Linux. It is written in Python and uses GTK for the user interface. This can be used as an alternative approach if you need to use the GUI for setting up Bluetooth. To install this Bluetooth manager, execute:

Step 6: Enable Auto Enable for Bluetooth

The AutoEnable=true option is used to automatically enable the Bluetooth adapter when certain events occur, such as on a boot, when the laptop lid is opened, or after suspending/resuming. This can be useful if you want to have Bluetooth ready without manually turning it on every time so now for that edit the Bluetooth configuration file:

sudo /etc/bluetooth/main.conf

Step 7: List Wireless Devices and Check their Status

This check is necessary for Bluetooth on Arch because it can help you troubleshoot Bluetooth issues by checking if your Bluetooth device is blocked or not. The status can be either Soft blocked or Hard blocked:

Here, soft blocked means that the device is disabled by software, while Hard blocked means that the device is disabled by a physical switch or BIOS settings. If the status for soft and hard blocked is yes, then unblock it by executing:

Step 8: Configure Bluetooth Audio for Arch Linux

If you want to connect audio devices with your Arch Linux, then you need to install pipwire which is an audio tool specifically for Linux distributions. This tool supports audio and video devices and applications with minimal latency and high security. It can also work as a drop-in replacement for other audio servers like PulseAudio and JACK.

Usually, this pipewire is pre-installed on Arch Linux and to confirm that check its version by executing:

If pipewire is not installed, then use the default package manager to install pipewire:

sudo pacman -Syu pipewire-pulse

In the older versions of Arch Linux PulseAudio was used and for its GUI you had to separately install its volume control and equalizer. So, to shift to pipwire Install the pipewire package and the pipewire-alsa, pipewire-jack, and pipewire-pulse packages to enable pipewire as a drop-in replacement for other audio servers. Further to install the GUI version of pipwire there are two types one is Helvum and the other is qpwgraph.

The main difference between qpwgraph and Helvum is their design and features. qpwgraph is a fork of qjackctl and has a persistent patchbay feature, which means it can save and restore your connections across sessions. It also has a transport control panel, which lets you start, stop, and rewind the audio server, to install it you have to clone its git repository first:

git clone https://aur.archlinux.org/qpwgraph-qt5.git

Now build the package for qpwgraph-qt5 using the make command:

cd qpwgraph-qt5</strong>

<strong>makepkg -si

Once the qpwgraph-qt5 is installed on Arch Linux launch it by executing:

You will see a window with a canvas that shows the nodes and ports of your pipewire graph. Nodes are the devices and applications that produce or consume audio or video streams, and ports are the inputs or outputs of each node. You can drag and drop nodes and ports to arrange them on the canvas, and you can link or unlink them by using keyboard and mouse shortcuts.

Helvum, on the other hand, is a newer and more modern GUI for pipewire, written in Rust and GTK. It has a sleek and intuitive interface, with drag-and-drop functionality and color-coded nodes. It does not have a persistent patchbay feature yet, but it is planned for future development. Furthermore, it also has a built-in terminal, which lets you run commands and scripts from within the GUI, to install it execute:

flatpak install flathub org.pipewire.Helvum

Once helvum is installed on Arch Linux launch it by executing:

flatpak run org.pipewire.Helvum

Operating the helvum on Arch is the same as the qpwgraph as mentioned previously. You can drag and drop nodes and ports to arrange them on the canvas, and you can link or unlink them by using keyboard and mouse shortcuts. You can also rename nodes and ports by double-clicking on them. You can access more options and settings from the menu bar or the toolbar.

 

Connecting Bluetooth Devices from Arch Linux

There are three ways to connect Bluetooth devices on Arch Linux which include:

  • Through Bluetooth Manager
  • Through GNOME
  • Through CLI (bluetoothctl)

1: Through Bluetooth Manager

The Bluetooth manager is primarily the blueman which we installed in step 5 to launch it search for Bluetooth manager in the activities menu and turn on the Bluetooth by clicking on Enable Bluetooth on the prompt:

Now search for the Bluetooth devices and look for the devices that you want to connect and to connect any device listed just click on it:

The key sign on the above menu bar serves the purpose of pairing the device with your Arch Linux system:

Further, the check sign on the menu bar is for trusting the respective device as it will make the connection more secure. To transfer any data to the connected device just click on the Send File option then select the file and after selecting the file click on OK to prompt the process:

2: Through GNOME Bluetooth

Another way to connect and pair the Bluetooth devices with Arch Linux is by using the GNOME Bluetooth settings. Navigate to the Bluetooth settings from the activities menu and from there turn on Bluetooth and after that you will see a list of devices under the search list. Click on the respective device that you want to connect for instance here I have connected my cell phone and Arch has given me a pin to pair:

Now in my cell phone Bluetooth menu, I will look for the Arch Linux system and then confirm it is the same pin as in the Arch system to establish a connection:

Now to send any data to any device other than the audio device connected to Arch through Bluetooth just click on it and after that click on Send Files. Next, select the respective data that you want to send and then click on the Select option to prompt the data transfer process:

3: Through CLI

The third way of connecting a Bluetooth device with Arch Linux is by using the BlueZ utility, which comes with bluetoothctl. It is the main utility for managing Bluetooth and is used to scan for nearby devices, connect, pair, trust, untrust, disconnect, and block devices using bluetoothctl commands. So first start the Bluetooth by executing:

Now to search the nearby devices you need to use the scan on command to initiate the process. There might be the possibility that it might already show the nearby devices:

Now as you can see in the image above there are a number of devices showing up with their MAC addresses. Here the NEW tag means that the state of the device is unchanged, whereas the CHG tag means that the state of the device is changed. So now to connect any of the devices just use the pair command along with the device MAC address shown in the search:

Pair <device-MAC-address>

Now as in the previous method, the bluetoothctl utility also gives a passcode for establishing a connection with the selected device so confirm the passcode on your respective device, and for confirmation on Arch enter yes:

Once the connection is successful, you will see a message of bonded in the CLI, and now you can interact with the connected device.

Now to remove the connected device just execute the remove command along with the MAC address:

remove <device MAC address>

Furthermore, if you need more information on various commands like trusting a device as we did in the first method then consult bluetoothctl help as it contains all of its commands along with their description:

Note: The bluetoothctl is a utility of BlueZ so it isn’t affected if Blueman Bluetooth Manager is not installed however to use Blueman you have to install BlueZ as there are some dependencies of BlueZ used by Blueman:

 

Setting up Bluetooth on Arch Linux on VirtualBox

The procedure mentioned previously in this guide will work only if you have installed it on a system, but if you have created an Arch Linux virtual machine then you won’t be able to connect any Bluetooth device with Arch. So, in that case, after following the above procedure when you turn on Bluetooth then you will get the connection to BlueZ failed error:

This is because the virtual machine is unable to detect the hardware for Bluetooth since it is created virtually. So, to make that work shut your Arch Linux and navigate to the Device Manager, and from there disable your Bluetooth driver:

Now turn on your Arch Linux virtual machine and once it is up and running again go to the Device Manager and enable the Bluetooth driver:

Upon enabling the Bluetooth driver, you may encounter the disappearance of the Bluetooth option in the Device Manager so in that case just reopen the Device Manager. If that’s not the case, then you have to install the Bluetooth driver and redo the whole process again.

Now upon successfully enabling the Bluetooth navigate to the Devices menu of VirtualBox and from there go to the USB option and select the Intel Corp [0002] option:

The option may differ so in that case you need to check for the Bluetooth hardware usually it is the same in most of the systems. Now your Bluetooth will be working and remember that you have to follow this procedure every time after you either shut down or reboot Arch Linux to use Bluetooth.

Conclusion

Bluetooth though is quite old technology but still it is being used for connecting nearby devices and most of the devices connected through Bluetooth are audio devices these days. So, to configure and set up Bluetooth on Arch you need to install BlueZ utility, and then you need to install Blueman if you need to use Bluetooth from GUI. If you have a GNOME-based environment, then you can simply go to the Bluetooth settings to turn it on and then pair any device.



Source link