[Pkg-lxde-maintainers] Bug#580509: lxpanel: Battery monitor shows 100% of capacity all the time

Milan Vancura milan at ucw.cz
Thu May 6 13:26:33 UTC 2010


Package: lxpanel
Version: 0.5.5-1
Severity: normal
Tags: squeeze

The problem has two parts: firstly the capacity percentage is computed wrongly
in case your ACPI directory contains file "energy_now" and secondly the
percentage is not updated so the bar size is still same as it was in the time
applet was started (the status charging/discharging is updated so the bar color
changes when you plug AC cabel in - but the bar size still remains same).

Both parts are fixed by the following patch:


diff -ur lxpanel-0.5.5-orig//src/plugins/batt/batt_sys.c lxpanel-0.5.5//src/plugins/batt/batt_sys.c
--- lxpanel-0.5.5-orig//src/plugins/batt/batt_sys.c	2010-02-06 20:45:38.000000000 +0100
+++ lxpanel-0.5.5//src/plugins/batt/batt_sys.c	2010-05-06 14:02:29.000000000 +0200
@@ -38,6 +38,13 @@
 battery* battery_new() {
     static int battery_num = 1;
     battery * b = g_new0 ( battery, 1 );
+    battery_reset(b);
+    b->battery_num = battery_num;
+    battery_num++;
+    return b;
+}
+
+void battery_reset( battery * b) {
     b->type_battery = TRUE;
     b->capacity_unit = "mAh";
     b->last_capacity_unit = -1;
@@ -49,12 +56,8 @@
     b->remaining_capacity = -1;
     b->present_rate = -1;
     b->state = NULL;
-    b->battery_num = battery_num;
-    battery_num++;
-    return b;
 }
 
-
 static gchar* parse_info_file(char *filename)
 {
     char *buf = NULL;
@@ -136,6 +139,8 @@
     };
     const gchar *sys_file;
 
+    battery_reset(b);
+
     while ( (sys_file = sys_list[i]) != NULL ) {
     
 	gchar *file_content;
@@ -150,7 +155,7 @@
 		    b->state = "available";
 	    }
 	    else if ( strcmp("energy_now", sys_file ) == 0 ) {
-		b->remaining_capacity = get_unit_value((gchar*) file_content) / 1000;
+		b->remaining_energy = get_unit_value((gchar*) file_content) / 1000;
 		if (!b->state)
 		    b->state = "available";
 	    }


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing'), (1, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-3-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

/sys/class/power_supply/BAT0 directory (filename: file content):

/sys/class/power_supply/BAT0/alarm: 1400000
/sys/class/power_supply/BAT0/current_now: 20365000
/sys/class/power_supply/BAT0/device: 
/sys/class/power_supply/BAT0/energy_full: 27910000
/sys/class/power_supply/BAT0/energy_full_design: 28800000
/sys/class/power_supply/BAT0/energy_now: 19710000
/sys/class/power_supply/BAT0/manufacturer: SANYO
/sys/class/power_supply/BAT0/model_name: 42T5247
/sys/class/power_supply/BAT0/power: 
/sys/class/power_supply/BAT0/power_now: 20365000
/sys/class/power_supply/BAT0/present: 1
/sys/class/power_supply/BAT0/serial_number:  1586
/sys/class/power_supply/BAT0/status: Charging
/sys/class/power_supply/BAT0/subsystem: 
/sys/class/power_supply/BAT0/technology: Li-ion
/sys/class/power_supply/BAT0/type: Battery
/sys/class/power_supply/BAT0/voltage_min_design: 14400000
/sys/class/power_supply/BAT0/voltage_now: 16584000

Versions of packages lxpanel depends on:
ii  libasound2              1.0.22-2         shared library for ALSA applicatio
ii  libatk1.0-0             1.30.0-1         The ATK accessibility toolkit
ii  libc6                   2.10.2-6         Embedded GNU C Library: Shared lib
ii  libcairo2               1.8.10-4         The Cairo 2D vector graphics libra
ii  libfontconfig1          2.8.0-2          generic font configuration library
ii  libfreetype6            2.3.11-1         FreeType 2 font engine, shared lib
ii  libglib2.0-0            2.24.0-1         The GLib library of C routines
ii  libgtk2.0-0             2.20.0-3         The GTK+ graphical user interface 
ii  libmenu-cache0          0.2.6-1          an implementation of the freedeskt
ii  libpango1.0-0           1.28.0-1         Layout and rendering of internatio
ii  libx11-6                2:1.3.3-3        X11 client-side library
ii  lxmenu-data             0.1.1-1          freedesktop.org menu specification
ii  zlib1g                  1:1.2.3.4.dfsg-3 compression library - runtime

Versions of packages lxpanel recommends:
ii  manpages-dev                  3.24-1     Manual pages about using GNU/Linux

Versions of packages lxpanel suggests:
ii  iceweasel [www-browser]       3.5.9-2    Web browser based on Firefox
ii  lxsession [lxsession-lite]    0.4.1-2    a lightweight X11 session manager
ii  menu                          2.1.43     generates programs menu for all me
ii  w3m [www-browser]             0.5.2-4    WWW browsable pager with excellent

-- no debconf information





More information about the Pkg-lxde-maintainers mailing list