Ubuntu bluetooth battery level

Check Bluetooth headphones battery status in Linux

Is it possible to get the battery status of Bluetooth headphones connected to Linux? Android shows it so I was wondering if it was possible.

6 Answers 6

I am not sure about the state under Ubuntu, but under Arch Linux you do not need to write your own scripts to get bluetooth battery information nowadays.

The bluez package has experimental support for querying bluetooth headset battery data. Simply enable experimental features by editing

Then, you just need to restart the bluetooth service using

systemctl restart bluetooth 

Reconnect to your device, and

should now also show the battery status. e.g.

Device 28:11:A5:47:6C:6E (public) Name: Cloud Walker Alias: Cloud Walker Class: 0x00240418 Icon: audio-headphones Paired: yes . Battery Percentage: 0x3c (60) 

The solution using upower as given by danjjl should also work now.

And now the battery level percentage should show up in Gnome Power settings dialog as well.

Thanks, just got this working on Arch thanks to your answer! It also gets it showing in the Power settings UI for Gnome too! Ubuntu must have enabled the Experimental bit in their upstream of bluez . I just added some UI screenshots as well as example output from bluetoothctl info . Oddly though, bluetoothctl info only shows one device, e.g. not my MX Master mouse battery as well. I’m looking forward to these battery levels showing natively in the system tray settings dropdown too!

I wrote a simple python script that does the job. It uses AT commands to communicate with the device via RFCOMM and prints the battery level if the device is supported.

(You need Python 3.6.0 or newer to run the script)

It might not work with all bluetooth headsets but I’ve provided a couple of workarounds in the ‘Issues’ page that might help.

@Qui-GonJinn it’s a command line tool. It simply prints the battery level, for example something like this: Battery level for XX:YY:ZZ:AA:BB:CC is 80%

Using port .2 I get is offline (16, ‘Device or resource busy’) . Using other ports I get is offline (111, ‘Connection refused’) .

In ubuntu you can go simply to settings->power to see the battery status of system and connected devices.

enter image description here

Yes, I know it’s a Microsoft Bluetooth mouse on a Linux System . but hey, Microsoft is the new cool company now 😉

This is what: systemctl status bluetooth

enter image description here

This is what: bluetoothctl devices shows:

enter image description here

The JBL was disconnected and the Creative speaker is connected with power. So the resulting ones with batteries (Keychron and Mouse) show up in the settings->power dialog.

Читайте также:  Elm327 bluetooth mini ios

NOTE: If upower -d not show the device, It’s power level may not display in settings .
// I had a mouse shown, but a headphone not.

Unfortunately, I don’t see the first section «Devices» on my machine. I’ve the same Ubuntu20.04.1 LTS.

Hmm, seems you don’t have any connected devices. Probably a last check if BT stack is running. You can check it with systemctl status bluetooth Which should state loaded and active. If that is the case you can use bluetoothctl which open an internal cli. Enter devices which should give a list of the connected devices. I add the outputs for my system in the answer above.

Seems to be dependent on the device. I found the issue and comment from the maintainer below in the gnome.org gitlab issues Source,see here: Quote: «.. the device needs to show up in the output of upower -d to show up in the Power Settings panel (whether that’s a laptop or a desktop). Right now, this means only devices which export their battery status in the kernel, and Bluetooth LE devices which export the battery via the BATT profile are supported...»

upower can be used from a terminal to list power devices, listening to device events and querying history and statistics.

If your device is listed by upower -e you can run upower —dump to retrieve the battery level of your device.

$ upower --dump . Device: /org/freedesktop/UPower/devices/mouse_dev_C1_FC_26_13_A9_58 native-path: /org/bluez/hci0/dev_C1_FC_26_13_A9_58 model: MX Anywhere 2S serial: C1:FC:26:13:A9:58 power supply: no updated: Wed 31 Dec 1969 06:00:00 PM CST (1550719462 seconds ago) has history: yes has statistics: no mouse present: yes rechargeable: no state: unknown warning-level: none percentage: 50% icon-name: 'battery-missing-symbolic' . 

Источник

Проверьте состояние батареи наушников Bluetooth в Linux

Возможно ли получить состояние батареи наушников Bluetooth, подключенных к Linux, Android показывает это, поэтому мне было интересно, если это было возможно??

6 ответов

Я не уверен насчет состояния в Ubuntu, но в Arch Linux в настоящее время вам не нужно писать собственные сценарии для получения информации о батарее Bluetooth.

Пакет bluez имеет экспериментальную поддержку запроса данных о батарее Bluetooth-гарнитуры. Просто включите экспериментальные функции, отредактировав

Затем вам просто нужно перезапустить службу Bluetooth, используя

systemctl restart bluetooth 

Повторно подключитесь к устройству и

теперь также должен показывать состояние батареи. например

Device 28:11:A5:47:6C:6E (public) Name: Cloud Walker Alias: Cloud Walker Class: 0x00240418 Icon: audio-headphones Paired: yes . Battery Percentage: 0x3c (60) 

Решение с использованием upower, предложенное danjjl, теперь также должно работать.

И теперь процент уровня заряда батареи также должен отображаться в диалоговом окне настроек Gnome Power.

Я написал простой скрипт на Python, который выполняет эту работу. Он использует AT-команды для связи с устройством через RFCOMM и печатает уровень заряда батареи, если устройство поддерживается.

Читайте также:  Как настроить gps bluetooth

(Для запуска скрипта вам понадобится Python 3.6.0 или новее)

Это может работать не со всеми bluetooth-гарнитурами, но на странице «Проблемы» я предложил несколько обходных решений, которые могут помочь.

В Ubuntu вы можете просто перейти в settings->power чтобы увидеть состояние батареи системы и подключенных устройств.

Да, я знаю, что это Bluetooth-мышь Microsoft в системе Linux. но, эй, Microsoft теперь новая крутая компания;)

upower может использоваться с терминала для составления списка устройств питания, прослушивания событий устройства и запроса истории и статистики.

Если ваше устройство указано upower -e Вы можете запустить upower —dump чтобы узнать уровень заряда батареи вашего устройства.

$ upower --dump . Device: /org/freedesktop/UPower/devices/mouse_dev_C1_FC_26_13_A9_58 native-path: /org/bluez/hci0/dev_C1_FC_26_13_A9_58 model: MX Anywhere 2S serial: C1:FC:26:13:A9:58 power supply: no updated: Wed 31 Dec 1969 06:00:00 PM CST (1550719462 seconds ago) has history: yes has statistics: no mouse present: yes rechargeable: no state: unknown warning-level: none percentage: 50% icon-name: 'battery-missing-symbolic' . 

Источник

Заряд аккумулятора блютус устройств. Как посмотреть?

Подскажите, каким образом можно посмотреть заряд аккумулятора в блютус устройстве? В андроиде готовых приложений — вагон и маленькая вагонетка, а вот в GNU/Linux системах я не нашел, ни приложений, ни консольных вариантов.

Видел у местных на скриншотах такое. В гнум3 точно есть, за KDE не ручаюсь.

Он обычно либо виден через upower, либо нет.

Есть стандартный фреймворк для отображения заряда всего, что можно. У меня он показывает заряд двух батарей ноутбука и bluetooth-клавиатуры производства еще покойной Palm.

Графические смотрелки есть как минимум в комплекте с GNOME и XFCE.

Выполни, пожалуйста, команду upower -d с подключенными устройствами и покажи вывод (например выложив на pastebin). Также укажи модели устройств, заряд которых пытаешься выяснить.

bluetooth-клавиатуры производства еще покойной Palm.

Херасе. Дай посмотреть, аж интересно стало

Есть стандартный фреймворк для отображения заряда всего, что можно

Главное, чтобы само устройство желало отдавать такую информацию. У меня есть очень дешевая bluetooth-клавиатура производства defender, и она никакую информацию не отдает. Но судя по ее устройству, она когда-то была клавиатурой на одноразовых батарейках, а потом китайцы сбоку приделали к ней литий-ионный аккумулятор со своим собственным контроллером заряда.

Естественно, но только вот батарейки или нет — не решающий фактор, та пальмовая как раз на батарейках.

Выполни, пожалуйста, команду upower -d с подключенными устройствами и покажи вывод (например выложив на pastebin).

Также укажи модели устройств, заряд которых пытаешься выяснить.

Наушники(Гарнитура) SVEN SEB-B270MV

  • [NEW] Controller B0:35:9F:08:76:B7 X-System [default]
  • [NEW] Device 20:13:08:12:03:3B Bluetooth Mouse
  • [NEW] Device 00:00:00:07:32:B7 SVEN SEB-B270MV
  • Agent registered
  • [CHG] Device 20:13:08:12:03:3B Connected: yes
  • [SVEN SEB-B270MV ]#

Графические смотрелки есть как минимум в комплекте с GNOME и XFCE.

Беглый поиск по синаптику ничего не дал, кроме того что к upower, установлен сам и к оному библиотека. Документацию доустановил, но толку не дало.

Читайте также:  Пропало устройство bluetooth windows 10

Alexonline ★★★★ ( 18.07.18 22:13:15 MSK )
Последнее исправление: Alexonline 18.07.18 22:20:43 MSK (всего исправлений: 1)

Тогда если тебе только посмотреть, то, похоже, не судьба.

Если ты решителен и хочешь добавить поддержку нового устройства несмотря ни на что, то придется освоить много нового и интересного, но я сам этого никогда не делал и особо не помогу.

Источник

Getting the Battery Status of a Bluetooth Device on Linux

Featured image for sharing metadata for article

Today while gaming — on Windows — I was alerted that my bluetooth mouse was low on battery. I realised that I didn’t have any way of keeping on top of top of it on (Arch) Linux.

It’s possible using the dbus-send interface to ask for the battery percentage, following this StackOverflow answer:

Unfortunately, this doesn't work out of the box as we receive the following error:
Error org.freedesktop.DBus.Error.UnknownObject: Method "Get" with signature "ss" on interface "org.freedesktop.DBus.Properties" doesn't exist 

As noted on the Arch Wiki, we need to enable the experimental mode by tweaking the bluetooth.service configuration to:

After a systemctl daemon-reload && systemctl restart bluetooth , we can now correctly get the status of the battery, showing it’s at 90%:

Jamie Tanna

Written by Jamie Tanna on Fri, 10 Dec 2021 21:58:48 UTC , and last updated on Mon, 14 Feb 2022 11:24:33 UTC .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

Has this content helped you? Did it solve that difficult-to-resolve issue you’ve been chasing for weeks? Or has it taught you something new you’ll be able to re-use daily?

Please consider supporting me so I can continue to create content like this!

This post was filed under articles.

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.

Want to get in touch? Drop me an email at hi@jamietanna.co.uk. I try to get back to everything, if I don’t reply in a couple of weeks, feel free to give me a nudge!

You can also check out a list of all the places /elsewhere you can find me.

© 2023 Jamie Tanna. Post content and code snippets licensing is detailed on respective pages, otherwise default to Creative Commons Attribution Non Commercial Share Alike 4.0 International and Apache License 2.0.
Site design released under the MIT License, based on Hack.css.
Proudly hosted on AWS using S3 + CloudFront, deployed by GitLab CI, and generated by d64e772843 on Mon, 14 Feb 2022 11:24:33 +0000..

Источник

Оцените статью
Adblock
detector