~ubuntu-branches/debian/sid/conky/sid

« back to all changes in this revision

Viewing changes to debian/patches/sysfs_battery

  • Committer: Bazaar Package Importer
  • Author(s): Kapil Hari Paranjape
  • Date: 2008-02-23 05:57:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080223055723-a0puda1aj4dfhag4
Tags: 1.4.9-4
* debian/patches/sysfs_battery:
  - handle systems where the POWER_SUPPLY_CHARGE_* values
    define battery status. Thanks to Stefan Ebner for
    help in debugging this.
    (Closes: #466878)
  - close battery status info file after each update.
* Enable support for RSS feed monitoring.
  - debian/rules: added "--enable-rss" to configure rules.
  - debian/control: additional build-dependencies on "libxml2-dev"
    and "libcurl4-gnutls-dev".
  - debian/NEWS.Debian: added comment about this change.
* Use autotools and libtool during build. (Thanks to tips from
  Henrique de Moraes Holschuh.)
  - debian/control: additional build-dependencies on "libtool"
    and "automake1.10"
  - debian/rules: added run of "autogen.sh" in "configure-stamp"
    target.
  - debian/rules: Define "RSS_LIBS" environment variable for
    "configure" to over-ride "pkg-config" which adds "libgssapi_krb5"
    to link libraries.
  - debian/rules: modified "clean" rule to clean autoconf generated
    files.
* Cleanup souce package of "src/tags" cruft left in by mistake
  in the previous upload.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Index: conky-1.4.9/src/linux.c
2
2
===================================================================
3
 
--- conky-1.4.9.orig/src/linux.c        2008-02-18 08:44:23.000000000 +0530
4
 
+++ conky-1.4.9/src/linux.c     2008-02-18 08:52:47.000000000 +0530
5
 
@@ -1257,10 +1257,35 @@
 
3
--- conky-1.4.9.orig/src/linux.c        2008-02-22 08:21:43.000000000 +0000
 
4
+++ conky-1.4.9/src/linux.c     2008-02-22 08:26:07.000000000 +0000
 
5
@@ -1257,10 +1257,36 @@
6
6
 2241<@jupet�kellari��> 1.16 1.2 0x03 0x00 0x00 0x01 99% -1 ? monitori p��ll� mutta ilman verkkovirtaa
7
7
 */
8
8
 
27
27
+       POWER_SUPPLY_ENERGY_NOW=11810000
28
28
+       POWER_SUPPLY_MODEL_NAME=IBM-92P1060
29
29
+       POWER_SUPPLY_MANUFACTURER=Panasonic
 
30
+  On some systems POWER_SUPPLY_ENERGY_* is replaced by POWER_SUPPLY_CHARGE_*
30
31
+*/
31
32
+
32
33
+#define SYSFS_BATTERY_BASE_PATH "/sys/class/power_supply"
38
39
 static FILE *acpi_bat_fp[MAX_BATTERY_COUNT];
39
40
 static FILE *apm_bat_fp[MAX_BATTERY_COUNT];
40
41
 
41
 
@@ -1308,6 +1333,8 @@
 
42
@@ -1308,6 +1334,8 @@
42
43
        static int idx, rep = 0, rep2 = 0;
43
44
        char acpi_path[128];
44
45
        snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
47
48
 
48
49
        init_batteries();
49
50
 
50
 
@@ -1322,12 +1349,112 @@
 
51
@@ -1322,12 +1350,117 @@
51
52
        memset (last_battery_str[idx], 0, sizeof (last_battery_str[idx]));
52
53
        memset (last_battery_time_str[idx], 0, sizeof (last_battery_time_str[idx]));
53
54
 
54
55
-       /* first try ACPI */
55
56
+       /* first try SYSFS if that fails try ACPI */
 
57
+
 
58
+       if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
 
59
+               sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
56
60
 
57
61
-       if (acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
58
62
+       if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
59
 
+               sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
60
 
+
61
 
+       if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
62
63
                acpi_bat_fp[idx] = open_file(acpi_path, &rep);
63
64
 
64
65
-       if (acpi_bat_fp[idx] != NULL) {
69
70
+               char charging_state[64];
70
71
+               char present[4];
71
72
+
72
 
+               fseek(sysfs_bat_fp[idx], 0, SEEK_SET);
73
 
+
74
73
+               strcpy(charging_state, "Unknown");
75
74
+
76
75
+               while (!feof(sysfs_bat_fp[idx])) {
95
94
+                               sscanf(buf, "POWER_SUPPLY_ENERGY_NOW=%d", &remaining_capacity);
96
95
+                       else if (strncmp(buf, "POWER_SUPPLY_ENERGY_FULL=", 25) == 0)
97
96
+                               sscanf(buf, "POWER_SUPPLY_ENERGY_FULL=%d", &acpi_last_full[idx]);
 
97
+                       else if (strncmp(buf, "POWER_SUPPLY_CHARGE_NOW=", 24) == 0)
 
98
+                               sscanf(buf, "POWER_SUPPLY_CHARGE_NOW=%d", &remaining_capacity);
 
99
+                       else if (strncmp(buf, "POWER_SUPPLY_CHARGE_FULL=", 25) == 0)
 
100
+                               sscanf(buf, "POWER_SUPPLY_CHARGE_FULL=%d", &acpi_last_full[idx]);
98
101
+               }
99
102
+
 
103
+               fclose(sysfs_bat_fp[idx]);
 
104
+               sysfs_bat_fp[idx] = NULL;
 
105
+
100
106
+               /* Hellf[i]re notes that remaining capacity can exceed acpi_last_full */
101
107
+               if (remaining_capacity > acpi_last_full[idx])
102
108
+                       acpi_last_full[idx] = remaining_capacity;  /* normalize to 100% */
163
169
                int present_rate = -1;
164
170
                int remaining_capacity = -1;
165
171
                char charging_state[64];
166
 
@@ -1491,6 +1618,8 @@
 
172
@@ -1491,6 +1624,8 @@
167
173
        int idx;
168
174
        char acpi_path[128];
169
175
        snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
172
178
 
173
179
        init_batteries();
174
180
 
175
 
@@ -1502,13 +1631,32 @@
 
181
@@ -1502,13 +1637,38 @@
176
182
        }
177
183
        last_battery_perct_time[idx] = current_update_time;
178
184
 
179
185
-       /* Only check for ACPI */
180
186
+       /* Only check for SYSFS or ACPI */
 
187
 
 
188
-       if (acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
 
189
+       if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
 
190
+               sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
181
191
+
182
192
+       if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
183
 
+               sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
184
 
 
185
 
-       if (acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
186
 
+       if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
187
193
                acpi_bat_fp[idx] = open_file(acpi_path, &rep);
188
194
 
189
195
        int remaining_capacity = -1;
191
197
+
192
198
+       if (sysfs_bat_fp[idx] != NULL) {
193
199
+               /* SYSFS */
194
 
+               fseek(sysfs_bat_fp[idx], 0, SEEK_SET);
195
 
+
196
200
+               while (!feof(sysfs_bat_fp[idx])) {
197
201
+                       char buf[256];
198
202
+                       if (fgets(buf, 256, sysfs_bat_fp[idx]) == NULL)
199
203
+                               break;
200
204
+
201
 
+                       if (strncmp(buf, "POWER_SUPPLY_ENERGY_NOW=", 24) == 0)
 
205
+                       if (strncmp(buf, "POWER_SUPPLY_CHARGE_NOW=", 24) == 0)
 
206
+                               sscanf(buf, "POWER_SUPPLY_CHARGE_NOW=%d", &remaining_capacity);
 
207
+                       else if (strncmp(buf, "POWER_SUPPLY_CHARGE_FULL=",25) != 0)
 
208
+                               sscanf(buf, "POWER_SUPPLY_CHARGE_FULL=%d", &acpi_last_full[idx]);
 
209
+                       else if (strncmp(buf, "POWER_SUPPLY_ENERGY_NOW=", 24) == 0)
202
210
+                               sscanf(buf, "POWER_SUPPLY_ENERGY_NOW=%d", &remaining_capacity);
203
211
+                       else if (strncmp(buf, "POWER_SUPPLY_ENERGY_FULL=",25) != 0)
204
212
+                               sscanf(buf, "POWER_SUPPLY_ENERGY_FULL=%d", &acpi_last_full[idx]);
205
213
+               }
 
214
+
 
215
+               fclose(sysfs_bat_fp[idx]);
 
216
+               sysfs_bat_fp[idx] = NULL;
 
217
+
206
218
+       } else if (acpi_bat_fp[idx] != NULL) {
207
219
+               /* ACPI */
208
220
                /* read last full capacity if it's zero */