Bug 324847 - List of batteries is not updated at runtime
Summary: List of batteries is not updated at runtime
Status: RESOLVED FIXED
Alias: None
Product: plasma4
Classification: Unclassified
Component: widget-battery (show other bugs)
Version: 4.11.1
Platform: Ubuntu Packages Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 251550 326648 (view as bug list)
Depends on:
Blocks: 334536
  Show dependency treegraph
 
Reported: 2013-09-12 16:16 UTC by Christian Schuerer
Modified: 2014-05-08 23:20 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.11.7


Attachments
Battery monitor connectSource patch (801 bytes, patch)
2013-09-16 09:12 UTC, Kai Uwe Broulik
Details
Battery monitor connectSource patch vol. 2 (1.21 KB, patch)
2013-10-27 10:16 UTC, Kai Uwe Broulik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Schuerer 2013-09-12 16:16:27 UTC
The battery monitor widget does not show batteries of newly added devices (e.g. if a wireless mouse is switched on after the battery monitor widget has been loaded). 

Reproducible: Always

Steps to Reproduce:
1. Log into KDE, but do not connect e.g. a wireless mouse device
2. After KDE and the widget has been loaded, turn on device
3. Check in battery monitor

Actual Results:  
List of available batteries is not updated (upower --monitor-detail does show it, though).

Expected Results:  
List of available batteries is updated
Comment 1 Kai Uwe Broulik 2013-09-13 07:51:37 UTC
Can you check whether the new battery immediately appears in plasmaengineexplorer too? (afaik it's now shipped with plasmate, no longer kde-workspace by default).
Open plasmaengineexplorer, navigate to the powermanagement engine, and *then* turn on your device (so we can see that the signal stuff works, otherwise it just re-reads the devices).
Thanks!
Comment 2 Christian Schuerer 2013-09-13 16:29:21 UTC
I checked as requested: Yes, the new battery appears immediately in plasmaengineexplorer.
Comment 3 Christian Schuerer 2013-09-15 15:06:40 UTC
I did some more tests: a battery which is available at the time the widget is loaded will be shown, even if it's removed and added again. But batteries of devices, which where added *after* the widget was loaded will never be shown.
Comment 4 Kai Uwe Broulik 2013-09-16 09:12:08 UTC
Created attachment 82334 [details]
Battery monitor connectSource patch
Comment 5 Kai Uwe Broulik 2013-09-16 09:12:39 UTC
Can you test whether this patch helps (and has no unwanted side-effects, eg. it still all works after suspending the machine etc)? Don't have a battery-powered machine near me atm. Thanks for your help!
Comment 6 Christian Schuerer 2013-09-16 18:42:25 UTC
I applied your changes and tested it - but unfortunately, it has some unwanted side-effects:

* Only the battery, which was added last, is shown
* If any battery is removed, the missing battery symbol is shown
Comment 7 Kai Uwe Broulik 2013-09-17 07:54:17 UTC
Ok, so I guess that if-clause was there for a reason :D
I need to more thoroughly test this then on a machine with batteries.
Thanks for testing!
Comment 8 Kai Uwe Broulik 2013-10-27 09:51:16 UTC
*** Bug 326648 has been marked as a duplicate of this bug. ***
Comment 9 Kai Uwe Broulik 2013-10-27 10:16:24 UTC
Created attachment 83148 [details]
Battery monitor connectSource patch vol. 2

This patch worked for me. Can you verify, please, so I can push it in time for 4.11.3? Thanks!
Comment 10 Aurelijus 2013-10-27 11:43:00 UTC
If somebody gives me instructions how to incorporate the patch, I could give a try.
Comment 11 Aurelijus 2013-10-27 12:52:28 UTC
OK, I have managed to update. So far it seems to work fine now!
Comment 12 Kai Uwe Broulik 2013-10-27 14:37:05 UTC
@Christian: Can you please test this patch as the last one didn't work for you. I cannot reliably trigger the problem here :-(
Comment 13 Christian Schuerer 2013-10-28 20:38:39 UTC
@Kai: thanks for the new patch. I applied and tested it, but there are still some problems, specially when batteries are removed.

* Adding a new battery works
* When the battery, which was added first, is removed, then all other battery  icons are removed, too

I will provide detailed steps in the next days.
Comment 14 Kai Uwe Broulik 2013-12-02 21:49:23 UTC
Ping?
Have you had any chance to play around a bit? :-) I cannot test your use case "Plug out the first battery and all the others disappear as well", as I only have a mouse which I could plug in and out which naturally comes after the built-in battery. :/
Comment 15 Aurelijus 2013-12-03 10:59:58 UTC
I did not observe any problems while trying in&out, etc. Works like a charm. On the other hand, I did not extensively use the second battery lately.
Comment 16 Jacob Welsh 2013-12-06 16:41:41 UTC
I'm having a slightly different problem but seems like it could be related.

I just migrated my homedir from a desktop running Fedora 17 to a laptop running Fedora 20 beta (KDE platform 4.11.3). I don't have a wireless mouse, but the desktop had a USB-attached UPS that registered as a battery. But now on the laptop, the battery plasmoid shows a red X and "No batteries available". The laptop battery is visible in upower and plasmaengineexplorer, and the battery monitor works if I log in to a fresh user account. There just doesn't seem to be a way to get the previously configured plasmoid to refresh itself.
Comment 17 Jacob Welsh 2013-12-06 20:23:16 UTC
Just noticed my battery monitor was working; seems to have found the new battery all by itself. I had installed some package updates but nothing KDE-related. Only other thing I can think of is I suspended and resumed the laptop, however I had done that before as well as rebooting.
Comment 18 Kai Uwe Broulik 2013-12-07 00:24:31 UTC
Can you all please test the patches I previously added to this bug report and see if any issues persist, especially when removing and adding the first battery (which is claimed to make all others disappear too). I want this fixed soon but I'm clueless :-/
Comment 19 Aurelijus 2013-12-07 12:54:30 UTC
OK, I tried playing around with both batteries and found only one minor issue:
after removing both batteries the correct icon with a red X appears, but hovering over with a cursor results in a popup/tooltip displaying both batteries (for example: battery 1: 100%, battery 2: 99%). Clicking on it displays a correct menu; only an automatic tooltip has a memory issue. Note, the tooltip is already wrong after one out of two being removed. To fix it: both batteries should be removed and, at least one, put back in.

Putting one or two batteries back in fixes everything and it works as expected (after ~5-s delay).
In short, for me the patch works fine, except a minor problem.
Comment 20 Kai Uwe Broulik 2013-12-07 13:23:42 UTC
Thanks for your feedback! I guess I forgot an updateLogic call which updates the tooltip there. Will post a new patch tomorrow.
Comment 21 Aurelijus 2014-01-30 21:01:20 UTC
Could at least the patch vol. 2 be submitted to the upstream?
As it is annoying to apply a patch each time after a KDE update when the file gets replaced. 
Thanks.

PS. vol. 3 with a tooltip fix might be even better
Comment 22 Kai Uwe Broulik 2014-01-30 21:09:59 UTC
Review Request 115409.
Maybe somebody has a better clue/solution ;)
Thanks!
Comment 23 Kai Uwe Broulik 2014-02-15 22:19:45 UTC
Git commit edd82448a60c36a66afec94cca1ba07741e1a121 by Kai Uwe Broulik.
Committed on 15/02/2014 at 22:18.
Pushed by broulik into branch 'KDE/4.11'.

Try to fix battery detection at runtime

REVIEW: 115409
FIXED-IN: 4.11.7

M  +4    -12   plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml

http://commits.kde.org/kde-workspace/edd82448a60c36a66afec94cca1ba07741e1a121
Comment 24 Elias Probst 2014-03-16 12:13:43 UTC
*** Bug 251550 has been marked as a duplicate of this bug. ***