Battery graph in tray icon is inaccurate

Bug #1767560 reported by Boris Gjenero
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
elementary-xfce (Ubuntu)
Confirmed
Undecided
Unassigned
xfce4-power-manager (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

xfce4-power-manager has a tray icon which shows current status and has a graph when a battery is inserted. The green bar in the icon should be showing current battery level, but it varies weirdly. If I place my mouse cursor over the icon the tooltip which appears shows the actual battery level. Now it is charging, 44%, but the graph is more like 80%. Earlier while discharging at around 28% the green was absent, as if it was 0%.

Both times I verified via the tooltip. So, the package has correct info but is graphing it incorrectly. It is not simply old info because it changes.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: xfce4-power-manager 1.6.1-0ubuntu1
Uname: Linux 4.16.2-041602-generic x86_64
ApportVersion: 2.20.9-0ubuntu7
Architecture: amd64
CurrentDesktop: XFCE
Date: Fri Apr 27 23:05:53 2018
InstallationDate: Installed on 2012-01-19 (2291 days ago)
InstallationMedia: Xubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111012)
SourcePackage: xfce4-power-manager
UpgradeStatus: Upgraded to bionic on 2018-03-11 (48 days ago)

Revision history for this message
Boris Gjenero (boris-gjenero) wrote :
Revision history for this message
Theo Linkspfeifer (lastonestanding) wrote :

It would be best to inform the upstream devs about this bug.

https://bugzilla.xfce.org/

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in xfce4-power-manager (Ubuntu):
status: New → Confirmed
Revision history for this message
Matias N. Goldberg (dark-sylinc) wrote :

This bug affects Xubuntu 18.04 but not 17.xx or earlier

It can be easily be reproduced on any desktop machine using https://github.com/hoelzro/linux-fake-battery-module (patch to compile on Xubuntu 18.04 is at the end)

I can see that:

In the range [60; 100] the full battery icon is displayed
In the range [30; 59] an icon that indicates around 60% battery level is displayed.
In the range [10; 30] an icon that indicates around 30-40% battery level is displayed
In the range [0; 9] an orange bar is displayed

Judging from the themes in 17.xx at /usr/share/icons/elementary-xfce/status/48 there's a lot more battery icon variety than what is being displayed (there's icons for 6 ranges!).

As for the fake module, apply this patch:

diff --git a/fake_battery.c b/fake_battery.c
index 2e3c04c..48da386 100644
--- a/fake_battery.c
+++ b/fake_battery.c
@@ -23,6 +23,7 @@
 #include <linux/power_supply.h>

 #include <asm/uaccess.h>
+#include <linux/uaccess.h>

 static int
 fake_battery_get_property1(struct power_supply *psy,
@@ -63,7 +64,6 @@ static int ac_status = 1;

 static char *fake_ac_supplies[] = {
     "BAT0",
- "BAT1",
 };

 static enum power_supply_property fake_battery_properties[] = {
@@ -99,14 +99,6 @@ static struct power_supply_desc descriptions[] = {
         .get_property = fake_battery_get_property1,
     },

- {
- .name = "BAT1",
- .type = POWER_SUPPLY_TYPE_BATTERY,
- .properties = fake_battery_properties,
- .num_properties = ARRAY_SIZE(fake_battery_properties),
- .get_property = fake_battery_get_property2,
- },
-
     {
         .name = "AC0",
         .type = POWER_SUPPLY_TYPE_MAINS,
@@ -220,7 +212,7 @@ handle_charge_changes(int ac_status, struct battery_status *battery)
 static ssize_t
 control_device_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
 {
- char kbuffer[1024]; /* limited by kernel frame size, 1K should be enough */
+ char kbuffer[512]; /* limited by kernel frame size, 1K should be enough */
     char *buffer_cursor;
     char *newline;
     size_t bytes_left = count;
@@ -232,8 +224,8 @@ control_device_write(struct file *file, const char *buffer, size_t count, loff_t
         return -EINVAL;
     }

- if(count > 1024) {
- printk(KERN_ERR "Too much data provided to /dev/fake_battery (limit 1024 bytes)\n");
+ if(count > 512) {
+ printk(KERN_ERR "Too much data provided to /dev/fake_battery (limit 512 bytes)\n");
         return -EINVAL;
     }

@@ -264,7 +256,7 @@ control_device_write(struct file *file, const char *buffer, size_t count, loff_t

     power_supply_changed(supplies[0]);
     power_supply_changed(supplies[1]);
- power_supply_changed(supplies[2]);
+ //power_supply_changed(supplies[2]);

     return count;
 }

This patch fixes a compilation error, a gcc warning, and disables the 2nd fake battery (by default the git repo creates 2 fake batteries)
And then run:

make
sudo insmod ./fake_battery.ko
echo 'charging = 0' | sudo tee /dev/fake_battery
echo 'capacity0 = 50' | sudo tee /dev/fake_battery

Revision history for this message
Theo Linkspfeifer (lastonestanding) wrote :

Is this a theme specific bug then?

Revision history for this message
Matias N. Goldberg (dark-sylinc) wrote :

I'm not fully certain. It appears like a theme specific bug, but it doesn't seem like the new xfce4-power-manager icon is using the theme's icons, but rather its own internal, or perhaps I'm looking at the wrong place.

Revision history for this message
Matias N. Goldberg (dark-sylinc) wrote :

Found upstream discussion: https://forum.xfce.org/viewtopic.php?id=12138

Apparently the problem is caused because xfce4-power-manager migrated to upower, which has only empty, caution, low, good, and full icon themes. That's 3 states + a caution + empty. IMO that's too few.

And yes, the icon themes are misleading. In /usr/share/icons/elementary-xfce/status/symbolic, battery-good-symbolic takes over at 30-59%, however the icon displayed looks more like 70% full or so.

Relevant files:
battery-caution-charging-symbolic.svg
battery-caution-symbolic.svg
battery-empty-charging-symbolic.svg
battery-empty-symbolic.svg
battery-full-charged-symbolic.svg
battery-full-charging-symbolic.svg
battery-full-symbolic.svg
battery-good-charging-symbolic.svg
battery-good-symbolic.svg
battery-low-charging-symbolic.svg
battery-low-symbolic.svg

GNOME icons are consistent with this scheme (it shows 3 bars).

Revision history for this message
Matias N. Goldberg (dark-sylinc) wrote :
Revision history for this message
Simon Steinbeiß (ochosi) wrote :

This is correct: https://bugs.launchpad.net/ubuntu/+source/xfce4-power-manager/+bug/1767560/comments/7

If you want to file a bugreport, it'd probably best be with the upstream elementary project (from where we inherit the battery icons) https://github.com/elementary/icons

Changed in xfce4-power-manager (Ubuntu):
status: Confirmed → Invalid
Changed in elementary-xfce (Ubuntu):
status: New → Confirmed
Revision history for this message
Simon Steinbeiß (ochosi) wrote :

Fwiw, I tried to follow/remain consistent with the Adwaita/Gnome icons.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.