Как подключить airpods к ubuntu

Обновлено: 03.07.2024

With ubuntu 19.10 I have been attempting to pair my Airpods with my laptop. There seems to be a problem with pairing and system is unable to add them as Bluetooth device. This happened after an upgrade from 19.04. Changing ControllerMode in /etc/bluetooth/main.conf seems to have no affect. Any help appreciated.

3 Answers 3

Try adding ControllerMode = bredr to /etc/bluetooth/main.conf file. Restart bluetooth service using the following command sudo systemctl restart bluetooth . Then try repairing with airpods, this worked for me in 19.10.

This worked for me too! I am using Sony WF-XB700 on Ubuntu 20.04. I think this issue is not airpods specific but due to Bluetooth 5.0 or whatever tech TWS headphones use. Changing ControllerMode to bredr in 20.04 does not work. Did you restart bluetooth service after that, it works on my end. @Sephethus it worked for me. Check that you have only one uncommented line with ControllerMode = bredr , I had ControllerMode = dual uncommented

I had the same problem. Changing ControllerMode doesn't work.

I Noticed that clicking airpod device to connect makes other devices unavailable to click and Bluetooth manager freezes.

Try to reload Bluetooth service then click connect again and airpods will appear as connected device.

Connected airpods

5,679 3 3 gold badges 28 28 silver badges 47 47 bronze badges

The bluetooth GUI didn't work and ControllerMode did nothing for me. I couldn't get it to pair, I just 'connected' in bluetoothctl and it worked. I fixed it like this:

Start the bluetooth controller in terminal

Inside the bluetoothctl, list the devices that it detects

Find your device. The number XX:XX:XX:XX:XX:XX is the name of your device to Ubuntu. Forget about the text "Airpods" or whatever, that just helps you find your number.

Trust your device

Then just connect it

I'm not sure if trusting did anything, but I know it was not trusted before because I ran info XX:XX:XX:XX:XX:XX and it told me. Not sure if I was already paired or not. Not sure if Airpods were in pairing mode when I connected. Connecting just worked. My ControllerMode is still the default. Type help in bluetoothctl to mess around with it. Ubuntu 20.04

If you have apple airpods or airpods pro, and sometimes want to use it with your Ubuntu machines, follow this guide! If you try to pair airpods without doing any of these steps, most likely the pairing process will never complete.

This is a compilation of ideas from few askubuntu posts. 1 2

Note: You should use HSP/HFP profile only when you need to use the airpods as microphone for example to make a zoom or google meet call. The sound quality in this mode can be quite terrible.

To enable pairing of airpods, you will need to update the ControllerMode to bredr from the default value of dual . This can be done by editing the file /etc/bluetooth/main.conf . Then restart the Bluetooth service using sudo /etc/init.d/bluetooth restart command.

You should be able to pair your airpods now and use it as headphones!

Enabling Airpods as Microphone

In order to have airpods work as microphones, you will need to enable HSP/HFP profile. However, Pulseaudio by default only supports HSP. In order to make HSP/HFP work, you have to enable HFP on pulseaudio which needs ofono . Here are steps to enable HFP on pulseaudio using ofono on Ubuntu 20.04.

Install ofono using: sudo apt install ofono

Configure pulseaudio to use ofono:

Goto /etc/pulse/default.pa , find the line load-module module-bluetooth-discover and change it to load-module module-bluetooth-discover headset=ofono .

Add the user pulse to group bluetooth to grant the permission: sudo usermod -aG bluetooth pulse

VERY IMPORTANT: To grant the permission, add the following code snippets to /etc/dbus-1/system.d/ofono.conf (before </busconfig> ):

In order to make ofono work, you have to provide a modem to it! You can install a modem emulator called phonesim (implemented by ofono ) to make it work:

Configure phonesim by adding the following lines to /etc/ofono/phonesim.conf :

Now, restart ofono service as:

Now you will need to define and enable few services to start the ofono-phonesim as service.

To run ofono-phonesim -p 12345 /usr/share/phonesim/default.xml on startup as a systemd unit, create the file /etc/systemd/system/ofono-phonesim.service (as root) with the following contents:

You will first need to use this githup repo:

As pointed in comments below, you might need a particular git commit for it to work the way it worked for me. The particular commit that I used the commit b3682c6bab99cbe301fa9bf4a2416c3f730d8bfd from the repo.

Now you can enable and make phonesim modem online by creating another systemd unit file that depends on the above ofono-phonesim systemd unit. Put the following contents in /etc/systemd/system/phonesim-enable-modem.service :

Then run the following commands to run both daemons:

Check if the service is running with

Finally, restart pulseaudio with pulseaudio -k .

Now you should be able to switch to HSP/HFP profile for airpods and use it as an input device / microphones.

airpods pairing as headphones, not headset

I was desperately searching on the websites, but I finally found this blog post which was really helpful to get familiar with a complementary Bluetooth stack. Here's the solution which I have changed and added to it according to my experience:

Install bluez Bluetooth stack (like a full set of Bluetooth drivers which allows the Linux OS direct access to Bluetooth):

sudo apt-get install bluez*

Optional: install Bluetooth manager, Blueman:

sudo apt-get install blueman

Load USB Bluetooth driver (Bluetooth dongle):

Restart bluetooth service:

sudo systemctl restart bluetooth

Add controller mode setting to be dual Bluetooth configuration /etc/bluetooth/main.conf change this mode to bredr or le in case you have problem with your AirPods:

Now try to pair your AirPods!

The source of the issue is that Ubuntu's Bluetooth driver doesn't cover AirPods' one.

My system specification:

  • Ubuntu 18.04.2 LTS
  • Mini Bluetooth 4.0 USB 2.0 CSR4.0 Dongle Adapter

You might need to choose either dual or bredr for ControllerMode in step 5.

enter image description here


dual is the default, I doubt setting it make any difference. There is another command to manage services which is IMO much easier to remember: sudo service bluetooth restart , sudo service bluetooth status . It comes with tap autocomplete so you can type sudo service hit TAB and see all available services or type sudo service blue + hit TAB which will show all services starting with blue or autocomplete to bluetooth Setting to bredr made pairing of AirPods Pro finally succeed - but only as headphones, not as headset. The volume was a bit too low so I had to activate Over-Amplification in sound settings to allow volume up beyond 100%. @Wlad I have the same partial solution, still no way to use as headset The same result can be achieved in much fewer steps with the other answer.

First, some words of context of what's might be going on for latest Ubuntu 21.04. Pulseaudio doesn't have complete/perfect support for HFP/HSP (the bluetooth standards for headset and headphones). Two options:

This guide will follow the both options, but don't do both (or both of them halfways). CHOOSE YOUR OWN ADVENTURE NOW.

  1. install PPA with this commands:
  1. Install pipewire!
  1. Disable pulseaudio
  1. Enable pipewire
  1. Check pipewire is integrated checking the output of this command

At this point you should have a working audio system!

First install some dependencies from a PPA:

Now, let's start with "the right stuff":

Go ahead and edit /etc/pulse/default.pa and find the line load-module module-bluetooth-discover and change it to load-module module-bluetooth-discover headset=ofono (pro-tip use command sudoedit /etc/pulse/default.pa to edit files of the system)

Edit the file /etc/dbus-1/system.d/ofono.conf and add this xml:

(not at the end, as that would produce a wrongly formatted XML)

  1. Edit the file /etc/ofono/phonesim.conf and put at the end of it:
  1. Checkout the scripts that help ofono start it's simulated modem:

Reboot your computer and pray to the old and the new gods.

Create a file called $HOME/prepare_for_meeting.sh with this content:

  1. TEST STEP. BYPASS IF YOU LIVE ON THE EDGE OF THE UNKNOWN ON EVERY MOMENT. Run this script to test if your are on the right path:

You should see something along this:

Either if you followed the Pipewire guide, or the Ofono one, now you should have an audio system that can use "Headset Head Unit" protocol. Let's click it! (and yes, now is a good moment to pray to "Mary, Undoer of Knots")

Enter Settings -> Sound -> Output, select "Headset Head Unit (HSP/HFP)" and what you will see that on "Input" also changes.

airpods connected in HSP/HFP mode

Hopefully you enjoyed all this scripting and hacking in your machine! If things go sideways, remember to undo stuff so that your computer doesn't become bloated and full of random scripts from people on the internet (specially from me).

airpods pairing as headphones, not headset

Установите bluez стек Bluetooth (например, полный набор драйверов Bluetooth, который позволяет ОС Linux прямой доступ к Bluetooth):

sudo apt-get install bluez *

Необязательно: установите диспетчер Bluetooth, Blueman:

sudo apt-get install blueman

Загрузите драйвер USB Bluetooth (ключ Bluetooth):

Перезапустите служба bluetooth :

sudo systemctl restart bluetooth

Добавить настройку режима контроллера как двойной конфигурация Bluetooth /etc/bluetooth/main.conf изменить этот режим на bredr или le на случай, если у вас возникли проблемы с вашими AirPods:

Теперь попробуйте выполнить сопряжение ваших AirPods!

Источник проблемы что драйвер Bluetooth в Ubuntu не поддерживает драйвер AirPods.

Спецификация моей системы :

  • Ubuntu 18.04.2 LTS
  • Mini Bluetooth 4.0 USB 2.0 CSR4.0 Dongle Adapter

Вам может потребоваться выбрать либо dual , либо bredr для ControllerMode в шаге 5.

enter image description here

Наконец-то мой микрофон работал с Ubuntu 18.04 и Airpods Pro. Похоже, это не только Airpods, но и Galaxy Buds и еще несколько вариантов bluetooth. Нам нужен HSP (низкий выход на динамик, но с включенным микрофоном), а не A2DP.

Во-первых, несколько слов из контекста того, что происходит. Pulseaudio не имеет полной / идеальной поддержки HFP / HSP (стандарты bluetooth для гарнитуры и наушников). Два варианта:

Это руководство будет следуйте первому варианту и интегрируйте его со своим стеком pulseaudio и bluetooth.

Теперь давайте начнем с «правильного»:

Отредактируйте /etc/pulse/default.pa и найдите строку load-module module-bluetooth-discover и измените его на load-module module-bluetooth-discover headset = ofono (pro-tip используйте команду sudoedit /etc/pulse/default.pa для редактирования файлов system)

Отредактируйте файл /etc/dbus-1/system.d/ofono.conf и добавьте этот xml:

  1. Отредактируйте файл /etc/ofono/phonesim.conf и укажите в конце:
  1. Ознакомьтесь со сценариями, которые помогают не запускать моделируемый модем:
  1. Создайте файл /etc/systemd/system/ofono-phonesim.service ( с root или sudoedit ):
  1. Создайте файл / etc / systemd / system /phonesim-enable-modem.service (снова с пользователем root ) с:

Перезагрузите компьютер и молитесь старым и новым богам.

ТЕСТОВЫЙ ШАГ. ОБХОДИТЕ, ЕСЛИ ВЫ ЖИВЕТЕ НА ГРАНИ НЕИЗВЕСТНОГО В КАЖДОЙ МОМЕНТ. Запустите этот сценарий, чтобы проверить, находитесь ли вы на правильном пути:

Вы должны увидеть что-то в этом месте:

airpods connected in HSP/HFP mode

Надеюсь, вам понравились все эти сценарии и взлом на вашей машине! Если что-то пойдет не так, не забудьте отменить кое-что, чтобы ваш компьютер не стал раздутым и не заполнился случайными скриптами от людей в Интернете (особенно от меня).

Читайте также: