Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 113275
Collapse All | Expand All

(-)xfce4-battery-plugin-0.3.0/panel-plugin/libacpi.c.orig (-10 / +25 lines)
Lines 40-45 Link Here
40
#include <stdlib.h>
40
#include <stdlib.h>
41
#include <sys/types.h>
41
#include <sys/types.h>
42
#include <dirent.h>
42
#include <dirent.h>
43
#include <glob.h>
43
44
44
#if HAVE_SYSCTL
45
#if HAVE_SYSCTL
45
#include <sys/sysctl.h>
46
#include <sys/sysctl.h>
Lines 179-184 Link Here
179
 
180
 
180
#endif
181
#endif
181
182
183
/* expand file name and fopen first match for reading */
184
static FILE *
185
fopen_glob(char *name)
186
{
187
  glob_t globbuf;
188
  FILE *fd;
189
190
  if (glob(name, 0, NULL, &globbuf) != 0)
191
    return NULL;
192
193
  fd = fopen(globbuf.gl_pathv[0], "r");
194
  globfree(&globbuf);
195
196
  return fd;
197
}
198
182
/* see if we have ACPI support */
199
/* see if we have ACPI support */
183
int check_acpi(void)
200
int check_acpi(void)
184
{
201
{
Lines 273-283 Link Here
273
  char *ptr;
290
  char *ptr;
274
  char stat;
291
  char stat;
275
292
276
  if (!(acpi = fopen ("/proc/acpi/ac_adapter/0/status", "r")))
293
  if ((acpi = fopen_glob("/proc/acpi/ac_adapter/*/stat*")) == NULL)
277
    if (!(acpi = fopen ("/proc/acpi/ac_adapter/ACAD/state", "r")))
294
    return -1;
278
      if (!(acpi = fopen ("/proc/acpi/ac_adapter/AC/state", "r")))
279
        if (!(acpi = fopen ("/proc/acpi/ac_adapter/ADP1/state", "r")))
280
	        return -1;
281
295
282
  fread (buf, 512, 1, acpi);
296
  fread (buf, 512, 1, acpi);
283
  fclose (acpi);
297
  fclose (acpi);
Lines 671-679 Link Here
671
  	  if (strlen(line) && strstr(line,"1")) return 1;
685
  	  if (strlen(line) && strstr(line,"1")) return 1;
672
    	  else return 0;
686
    	  else return 0;
673
    }
687
    }
674
    proc_fan_status="/proc/acpi/fan/FAN/state";
688
    if ((fp = fopen_glob("/proc/acpi/fan/*/stat*")) == NULL)
675
    if ( (fp=fopen(proc_fan_status, "r")) == NULL ) return 0; 
689
      return 0;
676
    
690
677
    fgets(line,255,fp);
691
    fgets(line,255,fp);
678
    fclose(fp);
692
    fclose(fp);
679
693
Lines 685-694 Link Here
685
{
699
{
686
#ifdef __linux__
700
#ifdef __linux__
687
  FILE *fp;
701
  FILE *fp;
688
  char *proc_temperature="/proc/acpi/thermal_zone/THRM/temperature";
689
  static char *p,line[256];
702
  static char *p,line[256];
690
703
691
  if ( (fp=fopen(proc_temperature, "r")) == NULL) return NULL;
704
  if ((fp = fopen_glob("/proc/acpi/thermal_zone/*/temperature")) == NULL)
705
    return NULL;
706
692
  fgets(line,255,fp);
707
  fgets(line,255,fp);
693
  fclose(fp);
708
  fclose(fp);
694
  p=strtok(line," ");
709
  p=strtok(line," ");

Return to bug 113275