-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Battery level reporting? #222
Comments
Battery status report is probably doable though work is ongoing in GNOME to have this systemwide and integrated into the proper config panels. Likewise with notifications, I'd rather have gnome send this in a generic manner for all battery-powered devices. |
Thanks for the info. Looking forward to see this, thank you. |
I think the system-level framework for doing this is upower, which has a daemon to communicate with (via DBUS?). It already has support for at least a few different Logitech mice, as evidenced in their udev rules. Not sure if it would be easy enough or worthwhile to pull and display the information it provides. |
It's dbus and we already have a decent dbus wrapper with But either way, the piper work for this would merely be accumulating the information and displaying it, no actual per-device work is necessary, that should all go into upower/kernel. |
Just adding my 2 cents here. In recent kernels, upower doesn't do anything but relay the information provided by the kernel for Logitech devices. They used to do it in userspace (which explains why the code is still there, in case you are not running a recent enough kernel), but userspace needs polling when kernel space can just push the information when available. I'll need to ping Logitech again regarding the recent gaming mice. They are not following any known and implemented protocol regarding their battery info. However, there are a little bit of preparatory work that needs to happen in the kernel before we can get to this point. |
does it? we can't subscribe to property updates on the dbus interface? |
Sorry, I was not talking at the same level:
So kernel is better, but from a client (piper) point of view, there is no differences |
@bentiss were you ever able to get in touch with Logitech regarding this topic? I've been looking into G703 battery readings recently and it's quite a headache without any documentation. |
Sorry, Last I remembered was that the battery reporting was not generic and each device had its own table of percentage/raw value associations. |
If you need to check things against an actual device, let me know, I have one and might be able to help. I also have a Windows laptop I can install the Logitech software on to do comparisons against. |
I'm not even sure if I'm in the right track, but I'd like to share what I found so far:
So I dropped the ones that errored out and probed the ones that did not once again with the mouse in wired mode (so, charging):
Here we can see only one feature showed promise, I did one final test by just probing feature If I'm right, maybe the battery data is reported by this feature after all, only in some weird way. Maybe the byte order is different in the response (since I was reusing the battery information from I also didn't look into the raw response for the features that didn't error out, so maybe the data is there, just not where I was expecting it to be. |
I set up a windows VM and captured the data sent by the windows driver to the mouse. When the mouse is charging, I get this response back: So I did a bit more probing and changed my function to send a short message instead of a long one when trying to initialize this feature. The message I ended up sending was this: Again, this is harder to make sense of, but the data returned seemed to be Another interesting tidbit I found was when comparing the calls to the feature at For reference, this is the exchange:
This is the full list of features reported by libratbag:
|
@pedrovanzella the protocol is very similar to the Unifying Receiver one, you can check out the spec for it. Battery level reporting there is at 0x1000, so that's the first hint. Now, the Unifying Receiver battery level reporting returns a value from 0 to 100, i.e. the percentage. The "Lightspeed" receiver (at least that's how Logitech refer to it, I think) instead returns the battery's voltage, which doesn't map to the 0..100 range 1 to 1. What Logitech do is they have a hash table of battery voltages, along with the percentage. What LGHub does is take the voltage and lookup the corresponding percentage. The tables are different for charge and discharge. I'm not sure where the hash table comes from (i.e. whether it's distributed with LGHub, fetched from Logitech servers, stored on the device, or maybe something different altogether), but you can actually access it locally. LGHub runs a web server at a certain port, which you can access from the browser to download the |
For what it's worth, Linux 5.2 will have support for Logitech wireless receivers, which will probably come with battery level reporting. |
Unfortunately no for the G900. And I guess same applies to the G403 and the other mice attached to the lightspeed receivers. @Lahvuun has a pretty good explanation :) @Lahvuun thanks a lot for the findings about the XML file. I'll see with Logitech if and how we can use those XML files. |
If anyone is interested in what they look like, but doesn't want to go through the trouble, here are the manifest and battery files for my g703: The |
@Lahvuun thanks for the LGHub tip. I've been digging through it and found another couple of interesting things. This is the battery dump for my G900: I also found a response with a feature list: Something interesting to note: Feature Maybe this is useful. |
Okay, so I figured out how the battery voltage is read, as well as most of the status bits and sent that as a PR to libratbag. I also have the xml files for all battery models, which lets me calculate percentage based on the voltage read. I figure this part is better done in piper, right? Is there currently a battery page for any kind of device in piper? I think I might look into that over the weekend, unless someone who knows the codebase better wants to jump into it. Let me know and I can share the xml files and my notes on how all this works. |
No, Piper is just a frontend displaying what it reads over DBus from libratbag. This too should go into libratbag. |
A comment on the upower issues indicates that at least some of this work might actually belong in the kernel, not sure how to make that happen though. I'll try to do a little digging. The driver for this is probably drivers/hid/hid-logitech-hidpp.c, and here's a best guess at the maintainers. Putting two and two together, one of those individuals has already commented in this thread... so they can probably do a better job offering suggestions than I. |
I think the lower levels of this stack (the Linux kernel, maybe even libratbag) should only report battery voltage and status, as that is what all devices will always report with feature 0x1001. The higher levels (upower maybe, probably piper) can deal with converting that into a percentage and what not. The reason for that is mostly that when a new device comes along, all we have to do is figure out the battery curve for it. So adding this new device to something like piper is easier (and it doesn’t litter the kernel with constants for different batteries, which I think they might oppose). |
I fully agree with @pedrovanzella |
Apparently kernel 5.2 can relay battery levels for 2.4GHz Logitech devices now for use in desktop GUIs. |
Sorry for resurrecting a fairly old thread, but this seems like the most relevant place to ask.. Now with kernel 5.3 out (at least in Ubuntu 19.10 beta) could someone help me with a cli command to get the battery percentage from my logitech g703? |
I would like to get the battery status of G900 as well. Anyone have had any success? |
There's a thread here with some more info: pwr-Solaar/Solaar#570 |
I'd really like this feature to be added, even if it's just for the piper app, rather than integrating with gnome. Any progress? |
The Solaar issue @maxdraki referenced appears closed as of 9 days ago in pwr-Solaar/Solaar#802, for what it's worth. Piper and Solaar appear to have complementary feature sets, so if Solaar has taken up the mantle of displaying battery status, maybe Piper doesn't need to. |
@qidydl I believe ratbag supports some devices that Solaar does not. For anyone who wants to get their current battery level, the device appears to be accessible here on Arch - note the exact name at the end of the path may differ depending upon what you have plugged in and your exact device (mine is a G305):
This gives me "Full" on a new battery, I think this will change to "High", "Normal", etc as it discharges:
Edit: Yep, it's just changed to "Normal". |
My mouse is a "G703 LIGHTSPEED Wireless Gaming Mouse w / HERO" and I'm not able to get the battery information. I know almost nothing about it. |
Is there any update to this? I am able to access the voltage of my G703 (over wireless) with |
Still waiting on Logitech to provide the people at Solaar with the numbers to convert voltage into a percentage, there's little point in displaying a voltage. |
It's mentioned in the linux-input list = https://www.spinics.net/lists/linux-input/msg70450.html |
This also would be good for the G903, I see voltage 4107mv (Charging) but I don't know the % of the battery via the Wireless Charging Pad/G903 |
Fell upon this recently. I tried finding the battery information n LGhub but couldnt find the XML dumps. Have they changed it ? Was looking for the G502/G915 and the Headset G933 |
This was finally implemented in b23cdfbddb73bad9d835baabd076ee4bfe1ab2bb by Hamza Mahfooz. FWIW, I think that the battery reporting should be done in the kernel, and made available to user-space by upower. Then Piper is free to consume that information to display it. Reimplementing battery reporting in the desktop, or warnings should be out of scope. |
Hello,
Would it be possible to add battery level reporting into this app?
I currently own a Logitech G903 wireless gaming mouse and I often forget to charge it.
I'm really happy to have found this app that lets me configure the LEDs and buttons, and the only thing that's missing (for me) is the battery level feature.
It would also be nice to send notifications when the battery is very low (e.g. at 15% and 5%) - that would be insanely helpful.
The text was updated successfully, but these errors were encountered: