! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
xfce4-panel-plugin-battery: shows 50%% if no battery found, settings do not work


Description Pablo Lezaeta 2012-12-05 16:41:12 CET
Self splicatory tittle

Reproduce: Add the plugin to the panel and the remove the battery (the plugin work good) now reboot whitout the baterry and watch again the plugin you can see the  (baterry icon)50%% in place and  noone of the setting work

more info need???
PD: not know how debug an applet
Comment 1 Raphael Groner 2012-12-13 09:17:33 CET
I can reproduce.

xfce4-battery-plugin 1.0.5-1

Linux schlebby 3.6.8-1-MANJARO #1 SMP PREEMPT Wed Nov 28 00:13:38 CET 2012 i686 GNU/Linux

I guess it's due to there's no /proc/acpi/battery/ available when there's no battery connected.
Comment 2 Pablo Lezaeta 2012-12-14 13:31:14 CET
Yes but in a Netbook or any battery capable system the battery can be removed and maintain connected to AC

Probably the best solution if if tno baterryc onected a 'no battery' message in place of all those 50%%

but in my test reconect the baterry on cold (aka login in) not reabilitate the plugin
Comment 3 Landry Breuil editbugs 2012-12-16 12:57:58 CET
I dont have a linux system to test that. Can you recompile the plugin with --enable-debug, reinstall it and look in .xsession-errors (or wherever your session logs its debug output) to see what the plugin says about proc/acpi/battery, and what codepaths are used ? Linux also uses sysfs /sys tree first, and only /proc after it.

Code is in http://git.xfce.org/panel-plugins/xfce4-battery-plugin/tree/panel-plugin/libacpi.c#n277 for the acpi check and http://git.xfce.org/panel-plugins/xfce4-battery-plugin/tree/panel-plugin/battery.c#n239 for the caller.

To my understanding on linux, if check_acpi_sysfs doesnt return 0, then check_acpi checks for /proc/acpi/battery, then if not found returns 2. The code in battery.c then fallbacks to apm_read, instead of properly propagating the failure to the plugin UI.
Comment 4 Mark Zhang 2012-12-17 07:49:25 CET
I have the same issue.
By the way, is there any requirement for kernel to make this pluging working?
Comment 5 Pablo Lezaeta 2012-12-21 16:20:29 CET
An I dicover that the percentages are inacurated at same time
the 100% is a real 100%
but the 1% is a real 0% because my applet report 1% and then run out of battery
Is not related to the 50%% but is related to the power managenment

and finally systemd have plans for replace acpi(d), I think is best relly on the kernel ans /sys and /proc reports intead of acpi for linux
Comment 6 bagujira 2013-02-05 14:18:57 CET
same issue here - for 3 years at least...
Comment 7 Kingmar Soares 2013-03-18 16:11:09 CET
I've fixed my xfce4 Battery plugin (not completely, but my plugin doesnt show the annoying 50%%).

The problem is that the deb package which is in the reppos comes with a libbattery.so compiled with a libbattery.c with errors.

I don't know C, so i can't fix the problem which makes settings dont affect the plugin when the battery in umplugged, but i fixed the message.. my plugin shows "No Battery" instead "50%%".

What i did:

Downloaded the source package: xfce4-battery-plugin-1.0.5 

edited the file: 


in this file edit line 698:  Change "50%%" with "No Battery"

Now compile the package, ./configure && make  BUT NOT INSTALL then copy the plugin:




In my case (Debian Wheezy amd_64) i use this location, to find yours download and extract your xfce4-battery-plugin precompiled package and search for the file libbattery.so, use the same location to copy your Fixed plugin file.

It's a middle solution, but i'm using linux since 1 month and i don't have enough knowledge to fix this for all the community but i'm sure that anyone who read that and have the needed knowledge can fix this bug without problems.

Thanks For ALL!!!

Comment 8 Pablo Lezaeta 2013-06-17 07:48:43 CEST
Based on Kigmar soares comment
that part fo 50%% is a translation problem easily fixable in transifex (unles that part is not translatable)

at this point I think that the built in batery monitor notify in the systreay can by fused (or replace) this applet

for now using the systreay icon provided by xfce4-powermanager 1.2.0 can by a drop in (ok, quasi) drop in replacenment

I drop this info for future users that want a workaround
Comment 9 Landry Breuil editbugs 2014-09-16 22:11:59 CEST
*** Bug 9140 has been marked as a duplicate of this bug. ***
Comment 10 Raphael Groner 2014-09-16 22:16:45 CEST
Possible (another) duplication bug #11161.
Comment 11 Sebastian Pipping 2014-09-16 22:17:00 CEST
*** Bug 11161 has been marked as a duplicate of this bug. ***
Comment 12 Landry Breuil editbugs 2014-11-23 21:42:44 CET
Mass-reassign all bugs from florian@ to goodies-dev@, thanks for the maintenance work! (and sorry for the bugmail spam..)
Comment 13 John Lindgren editbugs 2018-11-26 03:30:31 CET
Created attachment 8128 
Initially show/hide widgets according to user config.

Patch 1/2
Comment 14 John Lindgren editbugs 2018-11-26 03:32:19 CET
Created attachment 8129 
Initially show blank (rather than incorrect) labels.

Patch 2/2
Comment 15 Landry Breuil editbugs 2018-11-27 18:57:24 CET
(In reply to John Lindgren from comment #14)
> Created attachment 8129 
> Initially show blank (rather than incorrect) labels.
> Patch 2/2

I agree that the current state sucks, but i'm not sure showing blank values is the right solution. If you've hidden the progressbar, and have no values to display, you don't know where your plugin is, and you dont know if it's running or not.

Wouldnt it be better to show '?' as the default label and/or 'no value' in the tooltip ?
Comment 16 John Lindgren editbugs 2018-11-27 19:09:23 CET
(In reply to Landry Breuil from comment #15)
> Wouldnt it be better to show '?' as the default label and/or 'no value' in
> the tooltip ?

I'd suggest dashes '--' rather than question marks (just a cosmetic preference), but it doesn't matter much to me because I have only the progressbar visible.  There is currently no tooltip shown until the battery state is successfully read.  Setting a default tooltip like "Battery state unknown" wouldn't be a bad idea.

For my use case, patch 1/2 is more important since it keeps the labels I want hidden, hidden.
Comment 17 Git Bot editbugs 2018-11-29 17:40:58 CET
John Lindgren referenced this bugreport in commit 93de5176fe7d159d6060b6839358c3df6abfaa00

Initially show/hide widgets according to user config (bug #9594)

Comment 18 Landry Breuil editbugs 2018-11-29 17:42:39 CET
I still dont understand what's wrong with your systems, since here on an OpenBSD desktop without battery, i dont have '50%%' on the panel in the default config, and if i check all checkboxes in the config it only shows 'AC' (for - obviously- 'you're on AC'). Something specific to the linux code ? In the meantime i've pushed patch 1/2.
Comment 19 John Lindgren editbugs 2018-11-29 17:50:35 CET
It's nothing "wrong with our systems".  The initial label is very clearly set to '50%%' (cf. my patch 2/2 which changes that to a blank string) and if no battery is present, the label is never updated.

Look at check_acpi_sysfs() in libacpi.c:

	if ( batt_count == 0 )
#ifdef DEBUG
	  printf("DBG:No acpi support for sysfs. Trying procfs...\n");
		acpi_sysfs = 0;
		return 2;

If there is no battery present, the non-zero return value causes detect_battery_info() to return FALSE.  Then (apparently by design) update_apm_status() does not update any of the labels due to this line:

	if(!detect_battery_info(battmon)) return TRUE;
Comment 20 John Lindgren editbugs 2018-11-29 17:54:18 CET
One could easily change check_acpi_sysfs() to return 0 if an AC adapter but no battery is detected.  I can submit a patch if that's the desired behavior.

However, I still think that the label should never (even initially) be set to a false value such as '50%%'.
Comment 21 Landry Breuil editbugs 2018-11-29 18:15:58 CET
I dont know the linux code (nor can test it), but if fixing check_acpi_sysfs works for you that's fine for me :)
Comment 22 Landry Breuil editbugs 2018-11-29 18:20:15 CET
434e724 changes that to show -- instead of wrong info - still taking a patch for the default tooltip :)
Comment 23 John Lindgren editbugs 2018-11-29 18:34:54 CET
Thanks.  If I submit a patch for the ACPI code, I'll do it under a separate bug.  I think the fixes committed so far are enough to close this one.
Comment 24 Git Bot editbugs 2020-05-22 23:08:34 CEST
-- GitLab Migration Automatic Message --

This bug has been migrated to xfce.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/issues/6.

Please create an account or use an existing account on one of our supported OAuth providers. 

If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests

Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev

Bug #9594

Reported by:
Pablo Lezaeta
Reported on: 2012-12-05
Last modified on: 2020-05-22
Duplicates (2):
  • 9140 Configuration not respected if no battery present
  • 11161 xfce4-battery-plugin 1.0.5 displaying "50%%" (double percent)


Xfce-Goodies Maintainers
CC List:
8 users



Additional information