Bug 449036 - Displayed name of a Bluetooth device's battery is an HID name, not the alias which you can set in preferences
Summary: Displayed name of a Bluetooth device's battery is an HID name, not the alias ...
Status: RESOLVED WORKSFORME
Alias: None
Product: plasmashell
Classification: Plasma
Component: Power and Battery widget (show other bugs)
Version: master
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL: https://gitlab.freedesktop.org/upower...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-23 22:55 UTC by ratijas
Modified: 2022-10-30 05:04 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
KDE Bluetooth - apple magic keyboard's names (35.18 KB, image/png)
2022-01-23 22:55 UTC, ratijas
Details
The old/original/remote/HID name in the applet (41.01 KB, image/png)
2022-01-23 22:57 UTC, ratijas
Details
powermanagement data engine: magic keyboard's properties (128.88 KB, image/png)
2022-01-23 23:00 UTC, ratijas
Details
Sucessfully renamed MX Keys in both applets (436.19 KB, image/png)
2022-09-30 10:51 UTC, ratijas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ratijas 2022-01-23 22:55:42 UTC
Created attachment 145820 [details]
KDE Bluetooth - apple magic keyboard's names

SUMMARY

Either this product/component or it should go into powerdevil/frameworks-solid/bluedevil.

Apple Magic Keyboard is a Bluetooth-only device, and after pairing with a Linux system (either desktop or Android) it can be renamed in system/Bluetooth settings. Such renaming apparently only affects the operating system; while the device continues to identify itself as before (in my case it's supposedly the name of its previous owner -- I got a second-hand keyboard after all). It is said[1] that it can only be truly renamed from an OS X system, which I currently don't have at my disposal.

Both names may be visible on screen at the same time e.g. if you expand the list item in a Bluetooth applet, or just request info from `bluetoothctl`:

❯ bluetoothctl info 90:**:**:**:**:CD
Device 90:**:**:**:**:CD (public)
        Name: denis - клавиатура
        Alias: tragic keyboard
        Class: 0x00002540
        Icon: input-keyboard
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: yes
        WakeAllowed: yes
        LegacyPairing: no
        UUID: Human Interface Device... (00001124-0000-1000-8000-00805f9b34fb)
        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
        Modalias: usb:v05ACp0239d0050

The problem is that «Battery and Brightness» applet always displays the "Name" field, not a given "Alias". In the "powermanagement" Plasma data engine there are three naming fields per battery:
- Vendor
- Product
- Pretty Name

For instance, my laptop's battery is represented as

> { Vendor: "ASUSTeK", Product: "ASUS Battery", "Pretty Name": "Battery" }

but the poor tragic keyboard has both Product and Pretty Name equal to the same "device's remote name", even without vendor:

> { Vendor: <empty>, Product: "denis - клавиатура", "Pretty Name": "denis - клавиатура" }

On a closer look into kernel objects at /sys/bus/usb/devices/... it seems that the name is coming from HID_NAME in uevent data. Vendor data could've been extracted from HID_ID (like USB VID), but it's just not happening. AFAICT there's no API to directly tell HID device to change its name, which is probably why the system is resorting to "local" aliases.

STEPS TO REPRODUCE
1. Pair Appleⓡ Magic Keyboard™ with your system.
2. Rename it in System Settings.
3. Open up «Battery and Brightness» applet.

OBSERVED RESULT
You are seeing the "old" name, the HID name of a device.

EXPECTED RESULT
Since a proper renaming of this keyboard is not possible anywhere except on OS X, I'd at least expected to see an alias name in the applet.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.24.80
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.2
Kernel Version: 5.16.2-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-6700HQ CPU @ 2.60GHz
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 970M/PCIe/SSE2

bluez: 5.63-1
bluedevil: 1:5.23.5-1

ADDITIONAL INFORMATION

[1]: https://discussions.apple.com/thread/250109852
Comment 1 ratijas 2022-01-23 22:57:44 UTC
Created attachment 145821 [details]
The old/original/remote/HID name in the applet
Comment 2 ratijas 2022-01-23 23:00:17 UTC
Created attachment 145822 [details]
powermanagement data engine: magic keyboard's properties
Comment 3 Nicolas Fella 2022-01-31 16:00:46 UTC
bluez devices have two properties: 'Name' and 'Alias'. Changing the name in systemsettings is writing to 'Alias'.

upower seems to only consider Name  and ignore Alias, so I'm inclined to call this a upower bug. I don't see the Alias exposed anywhere in the upower interface
Comment 4 Nicolas Fella 2022-01-31 16:15:16 UTC
Checked the upower source and it does consider Alias: https://gitlab.freedesktop.org/upower/upower/-/blob/master/src/linux/up-device-bluez.c#L206

And after restarting upowerd and Plasma the alias shows up correctly in the applet, so the "only" problem seems to be runtime updating
Comment 6 Nate Graham 2022-02-01 14:56:47 UTC
Is there anything we can do here, or is this purely an upstream issue?
Comment 7 Nicolas Fella 2022-02-01 15:22:49 UTC
we could theoretically work around it by manually asking bluez for the device alias, but I really don't want to.

Assuming the upstream issues is fixed we also need to make sure that we actually handle a changing "battery" name properly
Comment 8 Bharadwaj Raju 2022-09-30 10:03:20 UTC
The upstream issue linked seems to be fixed, can this be closed? I don't have a Bluetooth device on hand which can confirm the fix.
Comment 9 ratijas 2022-09-30 10:51:40 UTC
Created attachment 152514 [details]
Sucessfully renamed MX Keys in both applets

I won't be able to test on that apple keyboard for another month or so, unless i find one around here. Worked on MX Keys though.

Also IIRC I renamed its HID name using friend's macbook — they seem to talk some extended protocol which is not available on Linux. At least, I definitely haven't seen that "denis - …" label in a while.
Comment 10 ratijas 2022-09-30 10:53:22 UTC
Set to WAITINGFORINFO, so it will remind me in 30 days
Comment 11 Bug Janitor Service 2022-10-15 04:56:04 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 12 Bug Janitor Service 2022-10-30 05:04:36 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!