--- panel-plugin/libacpi.c~ 2007-02-08 21:45:19.000000000 +0100 +++ panel-plugin/libacpi.c 2007-02-08 21:45:26.000000000 +0100 @@ -30,6 +30,7 @@ #include #include #include +#include #if HAVE_SYSCTL @@ -181,6 +182,22 @@ #endif #endif +/* expand file name and fopen first match */ +static FILE * +fopen_glob(const char *name, const char *mode) +{ + glob_t globbuf; + FILE *fd; + + if (glob(name, 0, NULL, &globbuf) != 0) + return NULL; + + fd = fopen(globbuf.gl_pathv[0], mode); + globfree(&globbuf); + + return fd; +} + /* see if we have ACPI support */ int check_acpi(void) { @@ -693,7 +710,7 @@ else return 0; } proc_fan_status="/proc/acpi/fan/*/state"; - if ( (fp=fopen(proc_fan_status, "r")) == NULL ) return 0; + if ( (fp=fopen_glob(proc_fan_status, "r")) == NULL ) return 0; fgets(line,255,fp); fclose(fp); @@ -706,10 +723,10 @@ { #ifdef __linux__ FILE *fp; - char *proc_temperature="/proc/acpi/thermal_zone/*0/temperature"; + char *proc_temperature="/proc/acpi/thermal_zone/*/temperature"; static char *p,line[256]; - if ( (fp=fopen(proc_temperature, "r")) == NULL) return NULL; + if ( (fp=fopen_glob(proc_temperature, "r")) == NULL) return NULL; fgets(line,255,fp); fclose(fp); p=strtok(line," ");