OBJ_alignr,
OBJ_alignc,
OBJ_i2c,
+#if defined(__linux__)
OBJ_i8k_version,
OBJ_i8k_bios,
OBJ_i8k_serial,
OBJ_i8k_right_fan_rpm,
OBJ_i8k_ac_status,
OBJ_i8k_buttons_status,
+#endif /* __linux__ */
OBJ_if_existing,
OBJ_if_mounted,
OBJ_if_running,
else
strcpy(bat, "BAT0");
obj->data.s = strdup(bat);
+#if defined(__linux__)
END OBJ(i8k_version, INFO_I8K)
END OBJ(i8k_bios, INFO_I8K)
END OBJ(i8k_serial, INFO_I8K)
END OBJ(i8k_right_fan_rpm, INFO_I8K)
END OBJ(i8k_ac_status, INFO_I8K)
END OBJ(i8k_buttons_status, INFO_I8K)
+#endif /* __linux__ */
END OBJ(buffers, INFO_BUFFERS)
END OBJ(cached, INFO_BUFFERS)
END OBJ(cpu, INFO_CPU)
OBJ(color) {
new_fg(p, obj->data.l);
}
+#if defined(__linux__)
OBJ(i8k_version) {
snprintf(p, n, "%s", i8k.version);
}
snprintf(p, n, "%s", i8k.buttons_status);
}
-
+#endif /* __linux__ */
#ifdef X11
OBJ(font) {
#define MAXSHOWDEVS 16
u_int64_t diskio_prev = 0;
+static short cpu_setup = 0;
static int getsysctl(char *name, void *ptr, size_t len)
{
struct cpu_load_struct fresh = { {0, 0, 0, 0, 0} };
long cpu_used, oldtotal, oldused;
+void get_cpu_count()
+{
+ int cpu_count = 0;
+
+ if (GETSYSCTL("hw.ncpu", cpu_count) == 0)
+ info.cpu_count = cpu_count;
+
+ info.cpu_usage = malloc(info.cpu_count * sizeof(float));
+ if (info.cpu_usage == NULL)
+ CRIT_ERR("malloc");
+}
+
void update_cpu_usage()
{
long used, total;
long cp_time[CPUSTATES];
size_t len = sizeof(cp_time);
-
+
+ if (cpu_setup == 0) {
+ get_cpu_count();
+ cpu_setup = 1;
+ }
+
if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) < 0) {
(void) fprintf(stderr, "Cannot get kern.cp_time");
}
fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
if ((total - oldtotal) != 0) {
- info.cpu_usage =
- ((double) (used - oldused)) / (double) (total -
- oldtotal);
+ info.cpu_usage[0] = ((double) (used - oldused)) / (double) (total - oldtotal);
} else {
- info.cpu_usage = 0;
+ info.cpu_usage[0] = 0;
}
oldused = used;