Categories: TutorialsUbuntu

How to use Bluetooth Headset on Ubuntu 20.04

By Simon Zambrovski, As more users switch to Linux for their daily computing needs, seamless remote communication has become essential. However, some users encounter challenges when trying to use Bluetooth headsets for conferencing.

Specifically, the current version of PulseAudio faces an issue with supporting Bluetooth headsets in both the A2DP profile (headphone mode with disabled microphone) and the HSP/HFP profile (lower headphone quality but with an enabled microphone). In this article, we explore potential solutions to address this issue and enhance the usability of Bluetooth headsets on Linux systems.

Steps to Enable Hands-Free Mode for Your Headset:

  1. Install Ofono
  2. Configure PulseAudio
  3. Set Up ofono-phonesim
  4. Configure Services Autostarts

1 Install Ofono : Open your console and run the following command:
sudo apt install ofono

2 Configure PulseAudio:

: In the file /etc/pulse/default.pa, locate the section where module-bluetooth-discover is loaded. Modify it as follows:

.ifexists module-bluetooth-discover.so

load-module module-bluetooth-discover headset=ofono

.endif

Execute the following command to add the user “pulse” to the “bluetooth” group:
sudo usermod -aG bluetooth pulse

Grant Permissions for ofono: Edit the file /etc/dbus-1/system.d/ofono.conf and add the following block as the last policy:

Read: How to manage sounds using PulseAudio on Ubuntu 18.04

3 Set Up ofono-phonesim

Install ofono-phonesim by running the following command:
sudo apt install ofono-phonesim

To create a virtual modem, create a new file named /etc/ofono/phonesim.conf with the following content:
[phonesim]

Driver=phonesim

Address=127.0.0.1

Port=12345

Feel free to choose a different port if you’re unable to use port 12345.

Manual mode

System Setup Completion: Your system setup is now complete for manual usage.

Start ofono-phonesim and Restart Bluetooth Stack: To use it, follow these steps:

Start ofono-phonesim by running the command:
ofono-phonesim -p 12345 /usr/share/phonesim/default.xml &
sudo service ofono restart
sudo service bluetooth restart

Test the Phonesim Modem: As a test, run the command:
/usr/share/ofono/scripts/list-modems

You should see the phonesim modem initialized.

Configure Bluetooth Settings: Open your Bluetooth settings (you can use Blueman or the built-in Ubuntu settings). Connect your Bluetooth device and switch it to the HSP/HFP profile.

Read: How to troubleshoot sound issues in Ubuntu 22.04

Setup automation

System Setup Completion: If your manual mode is functioning correctly, you’re almost there. However, manually executing the steps each time can be tedious. Let’s optimize your system startup to streamline this process.

Creating a systemd Unit File for Phonesim: To automatically start Phonesim when your system boots up, follow these steps:

  • Create a new file named phonesim.service in the directory /etc/systemd/system/.
  • Add the following content to the phonesim.service file:

Read: How to display your sound card details using the terminal on Ubuntu 22.04

Adjusting Port Settings: If you’ve modified the port in your modem definition, ensure that you update it accordingly.

Also, verify that the line containing ExecStart is correctly formatted.

Configuring ofono Service: To establish a dependency between ofono.service and phonesim.service, follow these steps:

Copy the original unit definition for ofono.service to /etc/systemd/system/ofono.service.

Modify the content of the copied file to:

Create the Unit File for Phonesim Modem:

Create a new unit file named /etc/systemd/system/ofono-modem.service.

Add the following content to the ofono-modem.service file:
[Unit]

Description=Enables Phonesim Modem

After=ofono.service

Requires=ofono.service

[Service]

Type=oneshot

ExecStart=/usr/share/ofono/scripts/enable-modem /phonesim

[Install]

WantedBy=multi-user.target

This service will run just after ofono.service and enable our modem during system boot.

Activate the Services on Boot:

Reload your systemd configuration and enable them by executing:

sudo systemctl daemon-reload

sudo systemctl enable phonesim

sudo systemctl enable ofono

sudo systemctl enable ofono-modem

Finally, reboot your system.

After the reboot, verify if the modem is directly connected by running the command: /usr/share/ofono/scripts/list-modems.

You should observe output similar to the following:

 

The post How to use Bluetooth Headset on Ubuntu 20.04 appeared first on net2.

Ubuntu Server Admin

Recent Posts

🚀 Deploy Elastic Stack on Ubuntu VPS (5 Minute Quick-Start Guide)

Here’s the guide to deploy Elastic Stack on Ubuntu VPS, with secure access, HTTPS proxying,…

4 days ago

🚀 Deploy Nagios on Ubuntu VPS

This guide walks through deploying Nagios Core on an Ubuntu VPS, from system prep to…

4 days ago

Shoryuken Has a New Maintainer, and v7.0.0 Is Almost There

After a decade under Pablo Cantero's stewardship, Shoryuken has a new maintainer - me. I'm…

1 week ago

A better way to provision NVIDIA BlueField DPUs at scale with MAAS

MAAS 3.7 has been officially released and it includes a bunch of cool new features.…

2 weeks ago

Ruby Floats: When 2.6x Faster Is Actually Slower (and Then Faster Again)

Update: This article originally concluded that Eisel-Lemire wasn't worth it for Ruby. I was wrong.…

2 weeks ago

MicroCeph: why it’s the superior MinIO alternative (and how to use it)

Recently, the team at MinIO moved the open source project into maintenance mode and will…

2 weeks ago