summaryrefslogtreecommitdiff
path: root/extra/icewm/icewm-1.3.8-remain_power.patch
blob: bbf650e9a48f95833b3393a4663fd3171f46cf34 (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
32
--- icewm-1.3.8-orig/src/aapm.cc	2013-11-17 17:54:39.000000000 +0100
+++ icewm-1.3.8/src/aapm.cc	2014-05-30 21:50:54.131868164 +0200
@@ -614,6 +614,11 @@
         }
         strcat3(buf, "/sys/class/power_supply/", BATname, "/current_now", sizeof(buf));
         fd = fopen(buf, "r");
+        if (fd == NULL) {
+        	strcat3(buf, "/sys/class/power_supply/", BATname, "/power_now", sizeof(buf));
+        	fd = fopen(buf, "r");
+	}
+
         if (fd != NULL && fgets(buf, sizeof(buf), fd)) {
                 //In case it contains non-numeric value
                 if (sscanf(buf,"%d", &BATrate) <= 0) {
@@ -697,7 +703,7 @@
            batCount++;
         }
 
-        if (!Tool &&
+        if (Tool &&
             taskBarShowApmTime &&
             BATpresent == BAT_PRESENT &&
             //bios calculates remaining time, only while discharging
@@ -706,7 +711,7 @@
             //did we parse the needed values successfully?
             BATcapacity_full >= 0 && BATcapacity_remain >= 0 && BATrate > 0) {
             BATtime_remain = (int) (60 * (double)(BATcapacity_remain) / BATrate);
-            sprintf(bat_info, "%d:%02d", BATtime_remain / 60, BATtime_remain % 60);
+            sprintf(bat_info, "%d:%02d (%3.0f%%)", BATtime_remain / 60, BATtime_remain % 60,100 * (double)BATcapacity_remain / BATcapacity_full);
         }
         else if (BATpresent == BAT_PRESENT &&
                  //did we parse the needed values successfully?