Introduction
Introduction Statistics Contact Development Disclaimer Help
tAdd cpu freq reading - spoon - dwm status utility (2f30 fork)
git clone git://src.adamsgaard.dk/spoon
Log
Files
Refs
LICENSE
---
commit 6e085bb0829b1f701633d571ab6ac3868d7ab681
parent 1a3626eb68f65133ab7257a07bfccc7f57def1da
Author: sin <[email protected]>
Date: Tue, 17 May 2016 14:57:34 +0100
Add cpu freq reading
Untested.
Diffstat:
M spoon.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/spoon.c b/spoon.c
t@@ -16,6 +16,7 @@
int dummyread(char *buf, size_t len);
int mpdread(char *buf, size_t len);
+int cpuread(char *buf, size_t len);
int battread(char *buf, size_t len);
int wifiread(char *buf, size_t len);
int dateread(char *buf, size_t len);
t@@ -28,6 +29,7 @@ struct ent {
/* reorder this if you want */
{ .fmt = "[%s] ", .read = mpdread },
{ .fmt = "[%s] ", .read = xkblayoutread },
+ { .fmt = "[%sMHz] ", .read = cpuread },
{ .fmt = "%s ", .read = battread },
{ .fmt = "%s ", .read = wifiread },
{ .fmt = "%s", .read = dateread },
t@@ -77,6 +79,7 @@ out:
#ifdef __OpenBSD__
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/sysctl.h>
#include <sys/ioctl.h>
#include <net/if.h>
t@@ -91,6 +94,21 @@ out:
#include <machine/apmvar.h>
int
+cpuread(char *buf, size_t len)
+{
+ int mib[2], cpuspeed;
+ size_t len;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_CPUSPEED;
+ len = sizeof(cpuspeed);
+ if (sysctl(mib, 2, &cpuspeed, &len, NULL, 0) < 0)
+ return -1;
+ snprintf(buf, len, "%d", cpuspeed);
+ return 0;
+}
+
+int
battread(char *buf, size_t len)
{
struct apm_power_info info;
t@@ -214,6 +232,12 @@ wifiread(char *buf, size_t len)
}
#else
int
+cpuread(char *buf, size_t len)
+{
+ return -1;
+}
+
+int
battread(char *buf, size_t len)
{
return -1;
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.