tConfigure cpu module from args - spoon - dwm status utility (2f30 fork) | |
git clone git://src.adamsgaard.dk/spoon | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 1299e08d72f8fd99c4d251c1c725bf7c3e438a23 | |
parent 208a0a20dc55c2b37db0fcf6326703d96369bc75 | |
Author: sin <[email protected]> | |
Date: Wed, 14 Mar 2018 10:39:13 +0000 | |
Configure cpu module from args | |
Diffstat: | |
M Makefile | 4 +--- | |
M config.def.h | 2 +- | |
M cpu.c | 7 +++++-- | |
M types.h | 4 ++++ | |
4 files changed, 11 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/Makefile b/Makefile | |
t@@ -11,9 +11,7 @@ include config.mk | |
CPPFLAGS_OpenBSD = -I/usr/X11R6/include -I/usr/local/include | |
LDFLAGS_OpenBSD = -L/usr/X11R6/lib -L/usr/local/lib | |
-CPPFLAGS_Linux =\ | |
- -I/usr/local/include\ | |
- -DPATH_CPU_FREQ=\"/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq\" | |
+CPPFLAGS_Linux = -I/usr/local/include | |
CPPFLAGS = $(CPPFLAGS_$(UNAME)) | |
LDFLAGS = $(LDFLAGS_$(UNAME)) | |
LDLIBS = -lX11 | |
diff --git a/config.def.h b/config.def.h | |
t@@ -7,7 +7,7 @@ struct ent ents[] = { | |
{ .fmt = "[%s] ", .read = countread, .arg = (char []){"/… | |
{ .fmt = "[%s] ", .read = mixread, .arg = NULL }, | |
{ .fmt = "[%s] ", .read = loadread, .arg = NULL }, | |
- { .fmt = "[%s] ", .read = cpuread, .arg = NULL }, | |
+ { .fmt = "[%s] ", .read = cpuread, .arg = &(struct cpuar… | |
{ .fmt = "[%s°] ", .read = tempread, .arg = "/sys/class… | |
{ .fmt = "%s ", .read = battread, .arg = &(struc… | |
{ .fmt = "%s ", .read = wifiread, .arg = NULL }, | |
diff --git a/cpu.c b/cpu.c | |
t@@ -1,6 +1,8 @@ | |
#include <err.h> | |
#include <stdio.h> | |
+#include "types.h" | |
+ | |
#ifdef __OpenBSD__ | |
#include <sys/sysctl.h> | |
t@@ -22,12 +24,13 @@ cpuread(void *arg, char *buf, size_t len) | |
int | |
cpuread(void *arg, char *buf, size_t len) | |
{ | |
+ struct cpuarg *cpuarg = arg; | |
FILE *fp; | |
int freq; | |
- fp = fopen(PATH_CPU_FREQ, "r"); | |
+ fp = fopen(cpuarg->freq, "r"); | |
if (fp == NULL) { | |
- warn("fopen %s", PATH_CPU_FREQ); | |
+ warn("fopen %s", cpuarg->freq); | |
return -1; | |
} | |
fscanf(fp, "%d", &freq); | |
diff --git a/types.h b/types.h | |
t@@ -3,6 +3,10 @@ struct battarg { | |
char *ac; | |
}; | |
+struct cpuarg { | |
+ char *freq; | |
+}; | |
+ | |
struct mpdarg { | |
char *host; | |
unsigned int port; |