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
33
34
35
36
37
38
39
40
41
42
43
44
45
|
icewm/src/acpustatus.cc | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/icewm/src/acpustatus.cc b/icewm/src/acpustatus.cc
index 5e959d6..b9e5450 100644
--- a/icewm/src/acpustatus.cc
+++ b/icewm/src/acpustatus.cc
@@ -315,6 +315,37 @@ int CPUStatus::getAcpiTemp(char *tempbuf, int buflen) {
}
closedir(dir);
}
+ else if ((dir = opendir("/sys/class/thermal")) != NULL) {
+ struct dirent *de;
+
+ while ((de = readdir(dir)) != NULL) {
+
+ int fd, seglen;
+
+ if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
+ continue;
+
+ sprintf(namebuf, "/sys/class/thermal/%s/temp", de->d_name);
+ fd = open(namebuf, O_RDONLY);
+ if (fd != -1) {
+ int len = read(fd, buf, sizeof(buf) - 1);
+ buf[len - 4] = '\0';
+ seglen = strlen(buf) + 4;
+ if (retbuflen + seglen >= buflen) {
+ retbuflen = -retbuflen;
+ close(fd);
+ closedir(dir);
+ break;
+ }
+ retbuflen += seglen;
+ strcat(tempbuf, " ");
+ strncat(tempbuf, buf, seglen);
+ strcat(tempbuf, " C");
+ close(fd);
+ }
+ }
+ closedir(dir);
+ }
return retbuflen;
}
|