+/*
+ * Reads the CPU temperature from /sys/class/thermal/thermal_zone0/temp and
+ * returns the temperature in degree celcius.
+ *
+ */
+static char *get_cpu_temperature_info() {
+ static char part[16];
+ char buf[16];
+ int temp;
+ int fd;
+
+ memset(buf, 0, sizeof(buf));
+ memset(part, 0, sizeof(part));
+
+ if ((fd = open(thermal_zone, O_RDONLY)) == -1)
+ die("Could not open %s\n", thermal_zone);
+ (void)read(fd, buf, sizeof(buf));
+ (void)close(fd);
+
+ if (sscanf(buf, "%d", &temp) != 1)
+ (void)snprintf(part, sizeof(part), "T: ? C");
+ else
+ (void)snprintf(part, sizeof(part), "T: %d C", (temp/1000));
+
+ return part;
+}
+