Package: procmeter3
Version: 3.5a-3
Followup-For: Bug #460263
Tags: patch

Attached patch makes powertop work for me when having multiple
batteries. (It does not multiply the battery index with the number
of battery outputs, so writes values in the wrong fields)

Hochachtungsvoll,
        Bernhard R. Link
diff -ru procmeter3-3.5a-original/modules/acpi.c procmeter3-3.5a/modules/acpi.c
--- procmeter3-3.5a-original/modules/acpi.c	2008-04-09 15:32:36.000000000 +0200
+++ procmeter3-3.5a/modules/acpi.c	2008-04-09 15:27:57.000000000 +0200
@@ -696,11 +696,13 @@
 {
  char *buf;
  int index = output - batt_outputs;
+ ProcMeterOutput *thisBattery;
  
  /* Is this a battery or a thermal output? */
  if (index >= 0 && index < acpi_batt_count * N_BATT_OUTPUTS) {
 	/* Battery. */
 	index = (output - batt_outputs) / N_BATT_OUTPUTS;
+	thisBattery = batt_outputs + index * N_BATT_OUTPUTS;
 
 	/* Only update every ten seconds, because acpi has a lot of
 	 * overhead, both here and in the kernel to generate those pretty
@@ -740,25 +742,25 @@
 
 			/* Status. */
 			status = scan_acpi_value(buf, acpi_labels[label_charging_state]);
-			sprintf(batt_outputs[index + 2].text_value, "%s", status);
+			sprintf(thisBattery[2].text_value, "%s", status);
 			
 			if (strcmp(status, "charging") == 0) {
 				/* Kill time left until empty. */
-				batt_outputs[index + 3].graph_value = PROCMETER_GRAPH_FLOATING(0);
-				sprintf(batt_outputs[index + 3].text_value,"n/a");
+				thisBattery[3].graph_value = PROCMETER_GRAPH_FLOATING(0);
+				sprintf(thisBattery[3].text_value,"n/a");
 				
 				/* Time left till full. */
-				batt_outputs[index + 4].graph_value = PROCMETER_GRAPH_FLOATING(timefull/batt_outputs[index + 4].graph_scale);
-				sprintf(batt_outputs[index + 4].text_value,"%i:%02i", (int) timefull / 60, (int) timefull % 60);
+				thisBattery[4].graph_value = PROCMETER_GRAPH_FLOATING(timefull/thisBattery[4].graph_scale);
+				sprintf(thisBattery[4].text_value,"%i:%02i", (int) timefull / 60, (int) timefull % 60);
 			}
 			else {
 				/* Time left till empty. */
-				batt_outputs[index + 3].graph_value = PROCMETER_GRAPH_FLOATING(timeleft/batt_outputs[index + 3].graph_scale);
-				sprintf(batt_outputs[index + 3].text_value,"%i:%02i", (int) timeleft / 60, (int) timeleft % 60);
+				thisBattery[3].graph_value = PROCMETER_GRAPH_FLOATING(timeleft/thisBattery[3].graph_scale);
+				sprintf(thisBattery[3].text_value,"%i:%02i", (int) timeleft / 60, (int) timeleft % 60);
 				
 				/* Kill time left until full. */
-				batt_outputs[index + 4].graph_value = PROCMETER_GRAPH_FLOATING(0);
-				sprintf(batt_outputs[index + 4].text_value,"n/a");
+				thisBattery[4].graph_value = PROCMETER_GRAPH_FLOATING(0);
+				sprintf(thisBattery[4].text_value,"n/a");
 			}
 			
 			if (acpi_batt_capacity[index] == 0) {
@@ -782,21 +784,21 @@
 			acpi_batt_capacity[index] = 0; 
 			
 			/* Kill time left until empty. */
-			batt_outputs[index + 3].graph_value = PROCMETER_GRAPH_FLOATING(0);
-			sprintf(batt_outputs[index + 3].text_value,"n/a");
+			thisBattery[3].graph_value = PROCMETER_GRAPH_FLOATING(0);
+			sprintf(thisBattery[3].text_value,"n/a");
 				
 			/* Kill time left till full. */
-			batt_outputs[index + 4].graph_value = PROCMETER_GRAPH_FLOATING(0);
-			sprintf(batt_outputs[index + 4].text_value,"n/a");
+			thisBattery[4].graph_value = PROCMETER_GRAPH_FLOATING(0);
+			sprintf(thisBattery[4].text_value,"n/a");
 		}
 		
 		/* Percent charged. */
-		batt_outputs[index + 0].graph_value = PROCMETER_GRAPH_FLOATING(percent/batt_outputs[index + 0].graph_scale);
-		sprintf(batt_outputs[index + 0].text_value,"%.0f%%", percent);
+		thisBattery[0].graph_value = PROCMETER_GRAPH_FLOATING(percent/thisBattery[0].graph_scale);
+		sprintf(thisBattery[0].text_value,"%.0f%%", percent);
 	
 		/* Charge/discharge rate. */
-		batt_outputs[index + 1].graph_value = PROCMETER_GRAPH_FLOATING((float)rate/batt_outputs[index + 1].graph_scale);
-		sprintf(batt_outputs[index + 1].text_value,"%i mA", rate);
+		thisBattery[1].graph_value = PROCMETER_GRAPH_FLOATING((float)rate/thisBattery[1].graph_scale);
+		sprintf(thisBattery[1].text_value,"%i mA", rate);
 	}
 
 	return(0);

Reply via email to