summaryrefslogtreecommitdiff
path: root/desktop/lxpanel/battery-applet.patch
blob: c2f5b93007efc952c4169e288d9b3bb19e370a10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From 93d9373574fcb0ed63cc4be7807343b018daad1a Mon Sep 17 00:00:00 2001
From: Marty Jack <martyj@linux.local>
Date: Thu, 19 Aug 2010 22:52:44 -0400
Subject: [PATCH] Battery percentage incorrectly always evaluates as 100 percent (Bug3006059)

---
 src/plugins/batt/batt_sys.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/plugins/batt/batt_sys.c b/src/plugins/batt/batt_sys.c
index 3c325b8..2ece803 100644
--- a/src/plugins/batt/batt_sys.c
+++ b/src/plugins/batt/batt_sys.c
@@ -150,7 +150,7 @@ void battery_update( battery *b ) {
 		    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";
 	    }
@@ -215,7 +215,7 @@ void battery_update( battery *b ) {
     if (b->last_capacity < MIN_CAPACITY)
 	b->percentage = 0;
     else
-	b->percentage = b->remaining_capacity * 100 / b->last_capacity;
+	b->percentage = ((float) b->remaining_energy * 100.0) / (float) b->last_capacity_unit;
 	    
     if (b->percentage > 100)
 	b->percentage = 100;