Site icon Linux Genie

How to Set up Bluetooth on Arch Linux?

How to Set up Bluetooth on Arch Linux

Bluetooth is a great way of communicating information wirelessly. Nowadays, every single device has built-in Bluetooth communication to transmit data across devices. Similarly, if you are the kind of person who prefers working with wireless gadgets like a mouse, keyboard, or headphones, then you must have encountered a situation where you have to connect your Bluetooth devices to your PC or Laptop.

Like every other OS, Arch Linux also has settings that allow you to enable Bluetooth and connect your devices to your system. However, it’s not as simple as on Windows, where you just have to click a single button to enable Bluetooth. Configuring Bluetooth on Arch can be a challenging task if you just started with Arch. Let’s check the detailed steps of configuring and connecting Bluetooth on your Arch Linux system.

Contents:

How to Set up Bluetooth on Arch Linux?

To use your Bluetooth on your Arch Linux system, you have to install the necessary utilities and configure the Bluetooth service. After that, you can pair your device with your system and test the audio quality. Now we will start with installing some prerequisites to set up Bluetooth on the Arch system.

Prerequisites

To set up Bluetooth on Arch Linux, you have to install the bluez package. This package provides the official Linux Bluetooth protocol stack to communicate with Bluetooth devices using various protocols and profiles.

Next, you have to set up the bluez-utils package. This package provides the bluetoothctl utility, which is a command-line tool to configure, pair, connect, and trust Bluetooth devices. You can also use it to scan for nearby devices, show device information, and send or receive files.

To install the bluez package on Arch Linux, you can use the default Pacman package manager:

sudo pacman -S bluez

Similarly, for installing the bluez-utils package, run:

sudo pacman -S bluez-utils

Alternatively, you can also try out the bluez-utils-compat AUR to additionally have the deprecated BlueZ tools. BlueZ is a software stack for Bluetooth devices on Linux systems. BlueZ provides various tools to manage and configure Bluetooth devices, such as rfcomm, hcitool, and hcidump. However, some of these tools are considered deprecated and are now not available in updated BlueZ versions.

The bluez-utils-compat AUR is a package that provides deprecated BlueZ tools for users who still need them. By installing bluez-utils-compat AUR, you can use the old BlueZ tools along with the new ones.

yay -S bluez-utils-compat

Lastly, you will need a GUI interface for managing and controlling the Bluetooth devices. If you are using any desktop environment with your Arch system, then most likely you will have pre-installed Bluetooth settings.

Installing Blueman Bluetooth Manager (GUI)

You can also try out the Blueman Bluetooth Manager. This Bluetooth manager is written in Python and uses GTK. It provides a graphical interface to manage Bluetooth devices, services, and settings. Blueman also integrates with PulseAudio to enable Bluetooth headsets and speakers. Blueman can be installed from the official Arch Linux repositories or the AUR.

sudo pacman -S blueman

After installation, a nice icon will appear here.

Checking Btusb Kernel Module

Now you have to check the btusb kernel module and confirm if it is loaded properly or not. The btusb kernel module is the generic driver for Bluetooth devices that use the USB interface.

To check the btusb kernel module, run:

lsmod | grep btusb

The lsmod command lists all the loaded kernel modules, and the grep btusb filters the output to show only the lines that contain the word btusb. This way, you can check if the btusb kernel module is loaded.

After the kernel module gets loaded, you will see some output. If nothing appears on your Arch console, then there’s some problem with your Bluetooth device. Maybe the btusb kernel module failed to load. Try updating your drivers or switching to another Bluetooth device.

Setting Bluetooth to Auto Enable

After a reboot, the Bluetooth adapter does not turn on automatically. So, if you want to auto-turn on the Bluetooth after boot, add or uncomment the line AutoEnable=true in the configuration file /etc/bluetooth/main.conf at the bottom in the [Policy] section.

Open the configuration file using the nano editor:

sudo nano /etc/bluetooth/main.conf

Search for the AutoEnable=true line and uncomment it:

After that, save the file and exit the editor.

This will make the Bluetooth daemon recognize and turn on all controllers, including the ones that are plugged in later. This way, you do not have to manually turn on the Bluetooth adapter every time you boot your system or plug in a new device.

Check Bluetooth Blockage

Before we can move toward enabling Bluetooth service, let’s check if Bluetooth is not blocked.

Check the Bluetooth status using the rfkill command:

rfkill list

The command rfkill list is used to list the wireless devices on your system and their status. The status can be either Soft blocked or Hard blocked. 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 setting.

If your Bluetooth is a Soft blocked, you can enable it by running:

rfkill unblock bluetooth

This command will not work if the device is Hard blocked, in which case you need to use the physical switch or BIOS setting to enable it.

Enabling Bluetooth Service

If you want to use Bluetooth devices with your Arch system, you need to start and enable the Bluetooth service on Arch. Otherwise, if the Bluetooth service is disabled, Bluetooth won’t be turned on.

First check the Bluetooth status, such as whether it is active, loaded, or enabled:

systemctl status bluetooth

As from the output, you can see Bluetooth service is disabled.

To start the Bluetooth service in the current session, run:

sudo systemctl start bluetooth.service

If you want to enable the Bluetooth service to start automatically at system boot, run:

sudo systemctl enable bluetooth.service

The above command does not start the service in the current session unless you use the –now option.

Finally, check the Bluetooth service again, after you have started and enabled it.

systemctl status bluetooth

You can see the Bluetooth service is enabled and ready to use. Now you can use any Bluetooth manager like Blueman to turn on all Bluetooth adapters and pair your system with Bluetooth devices.

Pairing Bluetooth Devices

To pair Bluetooth devices, you can use bluetoothctl or a graphical front-end such as GNOME Bluetooth or Blueman. These tools will help you to scan, pair, and connect Bluetooth devices.

Pairing Bluetooth Using Blueman

To pair Bluetooth devices using Blueman, launch it from the system tray or the menu.

Give permission to automatically enable Bluetooth.

Click the search button to scan for nearby devices.

Select a guest device to pair and click the pairing icon.

Now complete the pairing pin verification. Once connected, a confirmation will appear.

Pairing Bluetooth Using GNOME Bluetooth

Like Blueman, you can also use the default Bluetooth manager from the settings menu of your system. Like, I have GNOME installed on my system, so I can use it to connect with Bluetooth devices.

Open Bluetooth settings on your Arch system and enable Bluetooth switch. Your device will automatically begin searching for nearby devices.

Select the device you want to pair. A pairing PIN will appear confirmed to continue.

Similarly, confirm the PIN on the other device.

You will see the device will be connected successfully.

To unpair or remove a device, click on the device name, and select the Remove Device option.

Connecting Bluetooth Audio

If you want to use your Bluetooth device for audio, you may need to install pulseaudio and pulseaudio-bluetooth packages and configure them accordingly. You can also try the updated sound server Pipewire on your system.

Both Pulseaudio and Pipewire are sound servers that handle audio streams and devices. Pulseaudio is the default sound server in most Linux distributions, and it works well for consumer audio. Pipewire is a newer project that aims to support both consumer and professional audio, as well as video. It can dynamically switch between different buffer sizes and latency requirements, and it can replace both PulseAudio and JACK. Pipewire also has better Bluetooth codec support, and it can also be integrated with EasyEffects (PulseEffects).

With the new Archinstall script, now you can easily install Arch Linux and can configure the audio server for your system.

If your system has Pipewire, make sure that pipewire-pulse is installed:

sudo pacman -Syu pipewire-pulse

Or, if you prefer to use Pulseaudio, the bluez and pulseaudio-bluetooth will help you with audio communication.

To install Pulseaudio, run:

sudo pacman -S pulseaudio

For Pulse audio Bluetooth extension, run:

sudo pacman -S pulseaudio-bluetooth

Now start the Pulseaudio:

sudo systemctl pulseaudio start

If you want the Pulseaudio automatically start at boot, run:

sudo systemctl start pulseaudio

You can also use pavucontrol to switch the audio output between different devices. Pavucontrol is a graphical user interface for managing the PulseAudio sound server on Linux. Using it you can adjust the volume, switch inputs and outputs, mute and unmute sources, and more.

To install pavucontrol, run:

sudo pacman -S pavucontrol

To launch pavucontrol, run:

pavucontrol

Error: Connection Failed: Protocol not available

You may also need to fix some issues with a2dp (Advanced Audio Distribution Profile) protocol if your device uses it.

To fix it, follow these steps:

Install the pulseaudio-bluetooth-a2dp-gdm-fix package from the AUR. For GDM (GNOME Display Manager) Only.

This will enable a2dp on login if you use GDM. To do this, run:

cd ~/src

git clone https://aur.archlinux.org/pulseaudio-bluetooth-a2dp-gdm-fix.git

makepkg -i

Next, enable a2dp to connect. For this, create a script file with this content:

mkdir -p ~/.config/scripts/xorg

nano ~/.config/scripts/xorg/bt-auto-enable-a2dp.sh

Paste this content into the file:

Save and exit the file, then make it executable with this command:

chmod +x ~/.config/scripts/xorg/bt-auto-enable-a2dp.sh

Now create the udev rule to run the script when a Bluetooth device is connected. To do this, run this command:

sudo nano /etc/udev/rules.d/20-bt-auto-enable-a2dp.rules

Paste this content into the file.

Save and exit the file.

Restart your system or reload the udev rules with this command:

sudo udevadm control --reload-rules

Now you should be able to enjoy your Bluetooth audio device with a2dp.

Steps for Arch Linux Virtual Machine

Connecting audio devices on Arch Linux virtual machines is a bit tricky process, and you have to disable the Bluetooth adapter from your host machine first. Follow the given steps to enable Bluetooth on your Arch Linux virtual machine.

Step 1: First, disable the Bluetooth adapter on your Windows PC or Host machine, using the Device Manager.

Step 2: Now launch Arch Linux in VirtualBox.

Step 3: Now again open the Device Manager on your PC and this time enable the Bluetooth adapter.

Step 4: Now open the Arch Linux (Guest OS) virtual machine and enable the Bluetooth adapter by selecting Devices > USB from the top menu bar in VirtualBox. After that, choose the Bluetooth adapter. Now your Bluetooth is set to use on a virtual machine.

Conclusion

To set up Bluetooth on Arch Linux, first, you have to install the bluez and the bluez-utils package. The bluez package contains the official Linux Bluetooth protocol stack to communicate with Bluetooth devices, while the bluez-utils contain the bluetoothctl utility. After installing both these packages you can install any GUI Bluetooth manager like Blueman to manage, connect, and pair your system with Bluetooth devices. For audio servers, you can either use the Pulsewire or Pulseaudio. Both these servers can provide different audio codecs to communicate wirelessly.

 

Exit mobile version