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
|
--- xfce4-sensors-plugin-0.10.99.5.orig/panel-plugin/acpi.c 2008-08-06 01:56:00.063518101 +0200
+++ xfce4-sensors-plugin-0.10.99.5/panel-plugin/acpi.c 2008-08-06 03:11:08.635447284 +0200
@@ -445,7 +445,7 @@
void
refresh_acpi (gpointer chip_feature, gpointer data)
{
- char *file, *zone;
+ char *file, *zone, *state;
t_chipfeature *cf;
TRACE ("enters refresh_acpi");
@@ -472,8 +472,18 @@
break;
case STATE:
- file = g_strdup_printf ("%s/%s/state", ACPI_DIR_FAN, cf->devicename);
- cf->raw_value = strcmp(get_acpi_value(file), "on")==0 ? 1.0 : 0.0;
+ // get_acpi_value() expects a _full_ path (unlike get_acpi_zone_value() etc)!
+ file = g_strdup_printf ("%s/%s/%s/state", ACPI_PATH, ACPI_DIR_FAN, cf->devicename);
+ state = get_acpi_value(file);
+ // if get_acpi_value has returned NULL (=> the file hasn't been found)
+ // we display the fan as "off"
+ if(state==NULL){
+ DBG("get_acpi_value has returned NULL!");
+ cf->raw_value = 0.0;
+ break;
+ }
+ // on my box there is a \n after "on".. dunno if that's normal, so i only compare 2 chars
+ cf->raw_value = strncmp(state, "on", 2)==0 ? 1.0 : 0.0;
g_free (file);
/* g_free (cf->formatted_value);
cf->formatted_value = g_strdup_printf (_("%.0f"), cf->raw_value); */
|