How to get bluetooth headphones to work with Ubuntu

Managing bluetooth sound devices in Ubuntu can sometimes be a bit cumbersome (in my case I have Sony WH1000MX4 in the office and Bose QuietComfort 45 at home), especially if you are not familiar with the terminal or the intricacies of Linux. However, with the right tools and knowledge, it becomes quite simple. In this article, we will explore how to configure and manage Bluetooth in Ubuntu using the built-in options as well as Blueman's Bluetooth Manager.
Pre-requisites
Before diving into the process, make sure you have:
- Ubuntu Installed and Running
- Active Internet Connection
- Sudo Privileges
- Inbuilt or External Bluetooth Adapter
If you're unsure about which Bluetooth adapter to use with Linux, check out our previous post about Linux-compatible Bluetooth adapters.
Enabling Bluetooth Service
Ubuntu and many other Linux distributions typically come with Bluetooth pre-configured. To confirm if Bluetooth is running on your system, execute the following command:
If the service is active, you can proceed to the next steps. Otherwise, use the following commands to enable Bluetooth:
- For using a Bluetooth dongle, run:
- To start the Bluetooth service:
- To enable it on boot:
Finally, recheck the status using sudo systemctl status bluetooth.service
to ensure it's running.
Problem 1: Headphone does not pair or is refusing to connect with bluetooth / pulseaudio
Setting up BlueZ
Before you can manage your Bluetooth devices efficiently, you'll need to install BlueZ, the official Bluetooth stack for Linux. This software provides the necessary support for core Bluetooth layers and protocols.
First, update your repositories:
Then install BlueZ and its utilities:
With BlueZ set up, you can now proceed to install Blueman.
Installing Blueman
Blueman is an intuitive Bluetooth Manager that comes with a graphical interface. It offers functionalities like:
- Network connection via dial-up
- Audio device connection
- File transfer via OBEX
- Device pairing
- Input device connection
- Bluetooth network creation
Via Ubuntu Software Center
- Launch the Ubuntu Software Center.
- Search for "Blueman" and click on "Blueman Bluetooth Manager."
- Click 'Install' and provide the necessary authentication.
- Once installed, it can be started from the applications menu.
Via Terminal
Alternatively, you can also install Blueman through the terminal. Execute the following command:
After the installation, run Blueman by typing:
Note: Ensure that your Bluetooth adapter is connected before running this command.
Connecting Bluetooth Devices
Connecting to devices using Blueman is a breeze. Open Blueman, make sure your desired devices are discoverable and within range. You should be able to see them in the Blueman dashboard, where you can initiate the connection.
Problem 2: Headphones connect but ubuntu doesn't detect them as a sound device and I can't use them
Workaround: Adjust PulseAudio Configuration
To solve this problem, we will need to edit some PulseAudio configuration files. Here's how to do it:
Step 1: Edit the default.pa
File
- Open your terminal and type the following command to edit the file:
- Locate the following line:
- Comment it out by adding a
#
at the beginning of the line. It should look like this:
- Save the changes and close the editor.
Step 2: Edit the start-pulseaudio-x11
File
- In the terminal, run the following command:
- Find the snippet of code that looks like this:
- Add the following line right after that snippet:
- Save the changes and close the editor.
Step 3: Restart PulseAudio and Test
Now, it's advisable to restart the PulseAudio service to apply the changes. Execute the following command in the terminal:
Test your Bluetooth headphones to ensure that they now function correctly.