fix(power): Fix battery state / charge devices info. #710
+12
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #561.
Changes:
Before:
After:
Wrongfully using upower.on_battery (https://upower.freedesktop.org/docs/UPower.html) property instead of upower.device.state (https://upower.freedesktop.org/docs/Device.html) . The first one indicates whether it is a PC or laptop not if it is charging. The sibling properties of the object is LidIsClose :
I also found what KDE and lxqt is doing and what is using to derive this info:
Note: LQXT seems to have more complicated logic with the icons used, but nevertheless you can see what they use here to pick the right .svg: https://github.com/lxqt/lxqt-powermanagement/blob/master/src/iconproducer.cpp#L292-L300
Sending the dbus message from terminal:
2 -> Discharging
Caveat:
I only have a workstation , so I can't test the battery-applet (it doesn't show at all, but if there is a bug that there is it is hard to notice as i expect for laptop users to who only is visible to not show as charged and they might not notice that this is not changing when plugging it on power, or it might work because it is the main device?!!) that I believe is also wrong here:
https://github.com/pop-os/cosmic-applets/blob/master/cosmic-applet-battery/src/app.rs#L104-L127
I did test the on_battery example of the upower_dbus crate where is showing for my workstation that is false -> that would be interpreted that my workstation /desktop PC was charging with the current code!!!:
Edit: Found gnome-shell's implementation here: https://github.com/GNOME/gnome-shell/blob/d60bdc95faf3607ec579558074cf1ca919db041a/js/ui/status/system.js#L19-L85
Like i said for the system battery (not peripherals) they use the DisplayDevice (an alias object for the system) and the Upower.device.state interface/property