Bluetooth機器のバッテリー残量を表示させる

2023-04-03

KDE neonを使おう

t f B! P L

ウィジェットでBluetooth機器のバッテリー残量を表示 

 


2022年5月に489円で購入したこのBluetoothイヤホンをKDE neonに接続してもバッテリー残量が表示されないので「そういうもの」と思って気にしていませんでしたが実はKDE neonでもバッテリー残量表示に対応していると知りました。

KDE Plasma 5.15 Beta: Lightweight, Usable and Productive. - KDE Community

 

KDE Plasma 5.15から対応と書いてありますが5.27ではデスクトップに「バッテリーと明るさ」ウィジェットを表示させてもバッテリー残量の取得ができません。

バッテリー残量の表示には最新のupowerとbluezパッケージが必要と書いてあります。 

 

KDE neon 5.27

kernel 5.19

bluez 5.64

upower 0.99

 

bluezもupowerも最新のはずですが表示されないのはおかしいので原因を調べてみました。

 

bluezの実験的な機能を有効にする必要がある

 

まずはDiscoverで検索して出てきたsnap版のbluezとtest-snapd-upower-observe-consumerという2つのパッケージをインストールしてみましたがそれは全く意味はなく、すぐにアンインストールしました。 


How to view bluetooth headphone battery level in Manjaro KDE? : ManjaroLinux

 

これを読んで手持ちのBluetoothイヤホンが非標準的なコマンド(ATコマンド)を使っているのが原因である可能性を知りました。 

 

Install Bluez — Bluez documentation

 

これに書いてあるように/lib/systemd/system/bluetooth.serviceのExecStart=/usr/local/libexec/bluetooth/bluetoothdをExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimentalに変更してみました。

しかしこれはだめでした。

 

pq@nuc8i7beh:~$ ps aux | grep bluetoothd
root         802  0.0  0.0  10720  5588 ?        Ss   23:22   0:00 /usr/lib/bluetooth/bluetoothd
pq          6447  0.0  0.0   7668  2708 pts/1    S+   23:50   0:00 grep --color=auto bluetoothd

確認してみるとそもそもbluetoothdのパスが異なっています。これでは意味がありません。

この/usr/lib/bluetooth/bluetoothdはどこで起動されているのか調べてみましたがわかりませんでした。 

 

 I've been trying to enable the experimental feature of Bluez for about a week now. After a few days of frustration, it finally worked!! Kinda' confusing why my other bluetooth device did not display the bettery level, tho. BUT, I'm a happy boy now. : kde

 

で、ここに解決法がありました。

 

 /etc/bluetooth/main.confにExperimental = trueと書き込む

 

[General]
Experimental = true
# Default adaper name
# Defaults to 'BlueZ X.YZ'
#Name = BlueZ

 /etc/bluetooth/main.confの2行目にExperimental = trueと入力して再起動しました。

 

 

これで電源管理ウィジェットにBluetoothイヤホンのバッテリー残量を表示させることができました。upower -d でもBluetoothイヤホンが認識されるようになりました。

 

pq@nuc8i7beh:~$ upower -d
Device: /org/freedesktop/UPower/devices/headset_dev_12_1C_9B_46_6C_98
  native-path:          /org/bluez/hci0/dev_12_1C_9B_46_6C_98
  model:                YX-18
  serial:               12:1C:9B:46:6C:98
  power supply:         no
  updated:              2023年04月03日 00時05分37秒 (161 seconds ago)
  has history:          yes
  has statistics:       no
  headset
    warning-level:       none
    percentage:          80%
    icon-name:          'battery-missing-symbolic'

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         no
  updated:              2023年04月03日 00時05分01秒 (197 seconds ago)
  has history:          no
  has statistics:       no
  unknown
    warning-level:       none
    percentage:          0%
    icon-name:          ''

Daemon:
  daemon-version:  0.99.17
  on-battery:      no
  lid-is-closed:   no
  lid-is-present:  no
  critical-action: PowerOff

 

いまのところバッテリー残量が表示されないときもありますが原因がわかりません。

Bluetooth機器の電源を入れてからPCを起動してBluetooth機器に接続するとバッテリー残量が表示される可能性が高いように思います。

ブログ検索 by Blogger

Translate

最近のコメント

Created by Calendar Gadget

QooQ