Bug 320678 - battery applet doesn't notice that non-primary battery device was plugged in back
Summary: battery applet doesn't notice that non-primary battery device was plugged in ...
Status: RESOLVED FIXED
Alias: None
Product: plasma4
Classification: Plasma
Component: widget-battery (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Kai Uwe Broulik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-03 20:30 UTC by Arkadiusz Miskiewicz
Modified: 2013-06-06 19:51 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.11.0


Attachments
shows 0% (6.13 KB, image/jpeg)
2013-06-04 17:15 UTC, Arkadiusz Miskiewicz
Details
shows 10% percentage (11.92 KB, image/jpeg)
2013-06-04 17:16 UTC, Arkadiusz Miskiewicz
Details
Sort batteries (1.08 KB, patch)
2013-06-05 09:16 UTC, Kai Uwe Broulik
Details
red icon (4.90 KB, image/jpeg)
2013-06-06 06:30 UTC, Arkadiusz Miskiewicz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arkadiusz Miskiewicz 2013-06-03 20:30:17 UTC
https://bugs.kde.org/show_bug.cgi?id=317404 implemented battery information for devices like mouse or keyboard.

Unfortunately there is tiny bug. When device (trackball in my case) is unplugged then battery applet sees that immediately and stops showing battery percentage for it.

Testing on 4.10.3 with backported kdelibs/kdebase-workspace patches applied.
Plugging in back on the other hand is never noticed. Removing battery applet and adding it back makes applet see device.

plasma engine explorer sees unplugg and plugin back correctly, so the problem is only within applet.

Reproducible: Always
Comment 1 Kai Uwe Broulik 2013-06-04 15:37:25 UTC
Fixed. Forgot to connect the signal in Solid. Thanks for the feedback!
Comment 2 Arkadiusz Miskiewicz 2013-06-04 17:15:58 UTC
Created attachment 80301 [details]
shows 0%

Partially fixed.

When device gets plugged in back then upower sees:

Device: /org/freedesktop/UPower/devices/mouse_0003o046DoC52Bx0010
  native-path:          /sys/devices/pci0000:00/0000:00:1d.0/usb6/6-1/6-1:1.2/0003:046D:C52B.000F/0003:046D:C52B.0010
  vendor:               Logitech, Inc.
  model:                M570
  power supply:         no
  updated:              Thu Jan  1 01:00:00 1970 (1370365708 seconds ago)
  has history:          yes
  has statistics:       no
  mouse
    present:             no
    rechargeable:        yes
    state:               unknown
    percentage:          0%

so present == no and percentage  == 0%

After a while (after upower does another query cycle) data changes to:

Device: /org/freedesktop/UPower/devices/mouse_0003o046DoC52Bx0010
  native-path:          /sys/devices/pci0000:00/0000:00:1d.0/usb6/6-1/6-1:1.2/0003:046D:C52B.000F/0003:046D:C52B.0010
  vendor:               Logitech, Inc.
  model:                M570
  power supply:         no
  updated:              Tue Jun  4 19:08:53 2013 (21 seconds ago)
  has history:          yes
  has statistics:       no
  mouse
    present:             yes
    rechargeable:        yes
    state:               discharging
    percentage:          10%

so present == yes and percentage == 10%

Now two issues:
1) should device be shown if present == no? Not sure since percentage lies at that point

2) When mouse over applet it shows like on batt1.jpg screenshot but if I click on the applet I'm getting what's on batt2.jpg screenshot. Basically on 1 percentage is 0% while on 2 percentage is 10%. Looks like batt1 doesn't get update while batt2 is updated correctly. Note both screenshots were done after upower did its cycle and saw 10%.
Comment 3 Arkadiusz Miskiewicz 2013-06-04 17:16:18 UTC
Created attachment 80302 [details]
shows 10% percentage
Comment 4 Kai Uwe Broulik 2013-06-04 21:25:55 UTC
Git commit 444e364a8058935e17b41cbad08efa16165fd7fb by Kai Uwe Broulik.
Committed on 04/06/2013 at 23:25.
Pushed by broulik into branch 'master'.

Also update tooltip when DataModel changes

M  +1    -0    plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml

http://commits.kde.org/kde-workspace/444e364a8058935e17b41cbad08efa16165fd7fb
Comment 5 Kai Uwe Broulik 2013-06-04 21:31:15 UTC
Git commit 8108164ece1dcae38dcf1c353dd5b9e34011ac2c by Kai Uwe Broulik.
Committed on 04/06/2013 at 23:29.
Pushed by broulik into branch 'master'.

It seems UPower sets the "Is Present" property to false for newly added devices that have
not yet been probed. This is a contradiction to the specs that say this property is invalid
for non-primary batteries (such as mice).
Now also taking that into account for non-power-supply-batteries. Have to see if that causes
regressions for other devices. At least my Trackball works better now ;)

M  +3    -1    plasma/generic/applets/batterymonitor/contents/ui/BatteryItem.qml

http://commits.kde.org/kde-workspace/8108164ece1dcae38dcf1c353dd5b9e34011ac2c
Comment 6 Kai Uwe Broulik 2013-06-04 22:12:15 UTC
Git commit 95d03dc7ee1d0c981add17962e87e24da91eca40 by Kai Uwe Broulik.
Committed on 05/06/2013 at 00:11.
Pushed by broulik into branch 'master'.

Also handle not present batteries in the tooltip.

M  +7    -1    plasma/generic/applets/batterymonitor/contents/code/logic.js

http://commits.kde.org/kde-workspace/95d03dc7ee1d0c981add17962e87e24da91eca40
Comment 7 Arkadiusz Miskiewicz 2013-06-05 05:18:07 UTC
Works now, thanks!

One tinny issue - entries in the window after clicking on battery applet should be sorted to get constant behaviour IMO. Right now one time primary battery is first, other time mouse battery is first and so on. (same in tooltip window actually)

One comment - I liked having text percentage of primary battery being displayed on top of icon. Now that seems totally gone. Well I guess I can live with this but liked it anyway :)
Comment 8 Kai Uwe Broulik 2013-06-05 09:16:58 UTC
Created attachment 80309 [details]
Sort batteries

Thanks for your valuable feedback again!
Can you test this patch? It will sort the batteries by name and power supply state, ie:

Battery 1
Battery 2
A really cool mouse
Logitech Trackball
Some Keyboard
Zuper Cool Handy

About the percentage overlay, yes I liked that too, but it often caused problems because the item is wider than others with it) and didn't look really well either. That's why on a desktop it now shows the percentage below and in panel no more. But I made the compromise of instead making the battery icon more accurate. I think I we can live with that :-)
Comment 9 Arkadiusz Miskiewicz 2013-06-05 11:31:30 UTC
Patch works fine, sorts nicely when mouse or main battery is removed/added. Thanks!

The lack of percentage text is bigger problem. I've just tested it by draining battery to almost 0 and now I simply don't know when its safe to still work on my laptop.

Previously when I saw only few % of battery I was searching for power adapter or shutting down. Now while I still have 20% I only see one tiny "bar" on battery icon.

One bar doesn't tell me much - I don't know if it's 5%, 10%, 20%. Have to check by moving mouse over applet. Quick look with my eyes previously was much faster/better ;-)

In other words I lack quick indication where my battery is in 0-20% range which is most important range for me (if I miss close-to-zero condition bad things happen).

Maybe the text could be rendered vertically instead?

Also noticed that there is no visual indication that we enter or are in "ciricital battery" level for example.
Comment 10 Kai Uwe Broulik 2013-06-05 12:22:54 UTC
Do you also run kde-runtime master? There's a new battery icon which does 0-5% no bar, 5-15 red bar, 15-25 small white bar ...
Comment 11 Kai Uwe Broulik 2013-06-05 12:58:43 UTC
Git commit 115f62f0a1714a5c21a0a93e7e39d69ad9e4c83d by Kai Uwe Broulik.
Committed on 05/06/2013 at 14:57.
Pushed by broulik into branch 'master'.

Sort batteries alphabetically and by power supply.
Power supply batteries come first, peripheral batteries come after.

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

http://commits.kde.org/kde-workspace/115f62f0a1714a5c21a0a93e7e39d69ad9e4c83d
Comment 12 Arkadiusz Miskiewicz 2013-06-05 18:24:47 UTC
I'm using 4.10.4 with backported patches for the multiple batteries issue, so I don't have new icon. I'll try it later.

Thanks again.
Comment 13 Kai Uwe Broulik 2013-06-05 18:34:07 UTC
Just copy the file [kde-runtime] desktoptheme/air/icons/battery.svgz to /usr/share/kde4/apps/desktoptheme/default/icons (might vary a bit depending on your distribution). You might need to clear the plasma icon cache (delete the *plasma*.kcache files in your ~/.kde/cache-hostname). It should automatically detect that you're now using a battery svg with more finegrained icon and adapt.
Comment 14 Arkadiusz Miskiewicz 2013-06-06 06:30:25 UTC
Created attachment 80328 [details]
red icon

Ok, works as you described.

I can suggest improvements though :-) Not sure if possible but well.

If icon can slowly flash then:
0-5% no bar and flashing red battery icon (instead of white like its now)
5-10% no bar, red battery icon without flashing
10-15% - one red bar as currently, white battery icon
the rest as currently

if icon cannot flash then
0-5% no bar, red battery icon
5-10% one red bar, red battery icon
10-15% one red bar, white battery icon
the rest as currently

That would give better resolution for 0-15% and much stronger visual indication of critical levels.

By red battery icon I mean something like on screenshot  (ugly gimp work).
Comment 15 Kai Uwe Broulik 2013-06-06 19:51:31 UTC
Git commit a8fb105978786e1c5667b3dc7fc6f8c1aa7211b6 by Kai Uwe Broulik.
Committed on 06/06/2013 at 21:49.
Pushed by broulik into branch 'master'.

Animate battery icon when battery percentage is below 5%.
It's a subtle nice animation similar to the charging animation in the popup.
Imho the battery almost empty state is not really alerting as it's just a plain
white rectangle. This nice animation makes the user more aware that he should
really plug in his battery or he'll lose unsaved stuff.

M  +24   -0    plasma/generic/applets/batterymonitor/contents/ui/BatteryIcon.qml

http://commits.kde.org/kde-workspace/a8fb105978786e1c5667b3dc7fc6f8c1aa7211b6