Initial dockapps git repo
[dockapps.git] / wmpower-0.4.3 / src / power_management / dell / dell_lib.c
blobf63248e53706c36cf0007476f72076585b77db6a
1 #include <stdio.h>
2 #include <stdlib.h>
4 #include "lib_utils.h"
5 #include "power_management.h"
7 #define PROC_FILE "/proc/i8k"
9 /* we check for /proc/i18k */
10 int machine_is_dell(void)
12 FILE *fp = fopen(PROC_FILE, "r");
14 if (fp)
16 fclose(fp);
17 return 1;
20 return 0;
23 int dell_get_fan_status(void)
25 FILE *fp = fopen(PROC_FILE, "r");
26 int fan_status = 0;
27 int fan_2_status = 0;
29 if (!fp) return PM_Error;
31 if (fscanf(fp, "%*s%*s%*s%*s%d%d", &fan_status, &fan_2_status) == 2)
33 fclose(fp);
34 return (fan_status + fan_2_status);
37 fclose(fp);
38 return PM_Error;
41 int dell_get_temperature(void)
43 FILE *fp = fopen(PROC_FILE, "r");
44 int result;
46 if (!fp) return PM_Error;
48 if (fscanf(fp, "%*s%*s%*s%d", &result) == 1)
50 fclose(fp);
51 return result;
53 fclose(fp);
55 return PM_Error;