summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleafnode2004-05-20 22:19:29 (GMT)
committercvs2git2012-06-24 12:13:13 (GMT)
commit27a8ee6737209f8362517401f28a39ec30dfcbd0 (patch)
treed82cb0d719e59e9833dac348ce049eaebb78b8e3
parentb2e35af6df0fc30f47df16d304a77c9f8c5ba435 (diff)
downloadtorsmo-27a8ee6737209f8362517401f28a39ec30dfcbd0.zip
torsmo-27a8ee6737209f8362517401f28a39ec30dfcbd0.tar.gz
- fixing bug in average load display
- adding new feature - ability to specify battery number Changed files: torsmo-battery.patch -> 1.1 torsmo-load.patch -> 1.1
-rw-r--r--torsmo-battery.patch96
-rw-r--r--torsmo-load.patch21
2 files changed, 117 insertions, 0 deletions
diff --git a/torsmo-battery.patch b/torsmo-battery.patch
new file mode 100644
index 0000000..dd1f2a0
--- /dev/null
+++ b/torsmo-battery.patch
@@ -0,0 +1,96 @@
+diff -uNr torsmo-0.16-orig/linux.c torsmo-0.16/linux.c
+--- torsmo-0.16-orig/linux.c 2004-05-14 00:02:55.000000000 +0200
++++ torsmo-0.16/linux.c 2004-05-21 00:07:54.294243736 +0200
+@@ -395,7 +395,7 @@
+ 2241<@jupet kellari ö> 1.16 1.2 0x03 0x00 0x00 0x01 99% -1 ? monitori päällä mutta ilman verkkovirtaa
+ */
+
+-#define ACPI_BATTERY_PATH "/proc/acpi/battery/BAT1/state"
++#define ACPI_BATTERY_BASE_PATH "/proc/acpi/battery"
+ #define APM_PATH "/proc/apm"
+
+ static FILE *acpi_bat_fp;
+@@ -407,8 +407,10 @@
+
+ static double last_battery_time;
+
+-void get_battery_stuff(char *buf, unsigned int n) {
++void get_battery_stuff(char *buf, unsigned int n, unsigned int b) {
+ static int rep, rep2;
++ char acpi_path[128];
++ snprintf(acpi_path, 127, "%s/BAT%d/state", ACPI_BATTERY_BASE_PATH, b);
+
+ /* don't update battery too often */
+ if (current_update_time - last_battery_time < 29.5) {
+@@ -420,7 +422,7 @@
+ /* first try ACPI */
+
+ if (acpi_bat_fp == NULL && apm_bat_fp == NULL)
+- acpi_bat_fp = open_file(ACPI_BATTERY_PATH, &rep);
++ acpi_bat_fp = open_file(acpi_path, &rep);
+
+ if (acpi_bat_fp != NULL) {
+ int present_rate = -1;
+@@ -430,7 +432,7 @@
+ /* read last full capacity if it's zero */
+ if (acpi_last_full == 0) {
+ static int rep;
+- FILE *fp = open_file("/proc/acpi/battery/BAT1/info", &rep);
++ FILE *fp = open_file(acpi_path, &rep);
+ if (fp != NULL) {
+ while (!feof(fp)) {
+ char b[256];
+diff -uNr torsmo-0.16-orig/torsmo.c torsmo-0.16/torsmo.c
+--- torsmo-0.16-orig/torsmo.c 2004-05-13 23:31:04.000000000 +0200
++++ torsmo-0.16/torsmo.c 2004-05-21 00:06:49.443102608 +0200
+@@ -453,6 +453,7 @@
+ union {
+ char *s;
+ int i;
++ int b; // battery number
+ long l;
+ struct net_stat *net;
+ struct {
+@@ -518,6 +519,13 @@
+ OBJ(acpitemp)
+ END
+ OBJ(battery)
++ int no;
++ if (arg) {
++ sscanf(arg, "%d", &no);
++ } else {
++ no = 0;
++ }
++ obj->data.b = no;
+ END
+ OBJ(cpu)
+ need_cpu_usage = 1;
+@@ -872,7 +880,7 @@
+ snprintf(p, n, "%d", (int) get_acpi_temperature());
+ }
+ OBJ(battery) {
+- get_battery_stuff(p, n);
++ get_battery_stuff(p, n, obj->data.b);
+ }
+ OBJ(cpu) {
+ snprintf(p, n, "%d", (int) (cpu_usage*100.0));
+@@ -1848,7 +1856,6 @@
+
+ int main(int argc, char **argv) {
+ /* handle command line parameters that don't change configs */
+-
+ while (1) {
+ int c = getopt(argc, argv, getopt_string);
+ if (c == -1) break;
+diff -uNr torsmo-0.16-orig/torsmo.h torsmo-0.16/torsmo.h
+--- torsmo-0.16-orig/torsmo.h 2004-05-13 21:52:14.000000000 +0200
++++ torsmo-0.16/torsmo.h 2004-05-20 23:32:51.000000000 +0200
+@@ -30,7 +30,7 @@
+ double get_i2c_info(int *fd, const char *dev, const char *type, int n);
+ void get_load_average(double v[3]);
+ double get_acpi_temperature(void);
+-void get_battery_stuff(char *buf, unsigned int n);
++void get_battery_stuff(char *buf, unsigned int n, unsigned int b);
+
+ /* in torsmo.c */
+
diff --git a/torsmo-load.patch b/torsmo-load.patch
new file mode 100644
index 0000000..b296abf
--- /dev/null
+++ b/torsmo-load.patch
@@ -0,0 +1,21 @@
+--- torsmo-0.16-orig/torsmo.c 2004-05-21 00:14:44.675856248 +0200
++++ torsmo-0.16/torsmo.c 2004-05-21 00:17:02.518900920 +0200
+@@ -910,13 +910,13 @@
+ get_load_average(v);
+
+ if (obj->data.loadavg[2])
+- snprintf(p, n, "%.2f %.2f %.2f", v[obj->data.loadavg[0]-1],
+- v[obj->data.loadavg[1]-1], v[obj->data.loadavg[2]-1]);
++ snprintf(p, n, "%.2f %.2f %.2f", v[obj->data.loadavg[0]],
++ v[obj->data.loadavg[1]], v[obj->data.loadavg[2]]);
+ else if (obj->data.loadavg[1])
+- snprintf(p, n, "%.2f %.2f", v[obj->data.loadavg[0]-1],
+- v[obj->data.loadavg[1]-1]);
++ snprintf(p, n, "%.2f %.2f", v[obj->data.loadavg[0]],
++ v[obj->data.loadavg[1]]);
+ else if (obj->data.loadavg[0])
+- snprintf(p, n, "%.2f", v[obj->data.loadavg[0]-1]);
++ snprintf(p, n, "%.2f", v[obj->data.loadavg[0]]);
+ }
+ OBJ(hr) {
+ new_hr(p, obj->data.i);