Introduction
Introduction Statistics Contact Development Disclaimer Help
tAdd load average plugin - spoon - dwm status utility (2f30 fork)
git clone git://src.adamsgaard.dk/spoon
Log
Files
Refs
LICENSE
---
commit 96931ea266470a6a7b1f302837963dbb4351996e
parent f5b1dc411d5c78695948f0c2aa44e3c8608a4428
Author: sin <[email protected]>
Date: Thu, 13 Oct 2016 10:42:31 +0100
Add load average plugin
Diffstat:
M Makefile | 6 +++---
M config.def.h | 1 +
A load.c | 14 ++++++++++++++
M spoon.c | 1 +
4 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/Makefile b/Makefile
t@@ -1,9 +1,9 @@
VERSION = 0.2
PREFIX = /usr/local
-DISTFILES = spoon.c batt.c wifi.c cpu.c temp.c mix.c date.c mpd.c\
- xkblayout.c strlcpy.c strlcat.c util.h config.def.h\
+DISTFILES = spoon.c batt.c wifi.c cpu.c temp.c mix.c date.c load.c\
+ mpd.c xkblayout.c strlcpy.c strlcat.c util.h config.def.h\
Makefile LICENSE configure
-OBJ = spoon.o batt.o wifi.o cpu.o temp.o mix.o date.o mpd.o xkblayout.o\
+OBJ = spoon.o batt.o wifi.o cpu.o temp.o mix.o date.o load.o mpd.o xkblayout.o\
strlcpy.o strlcat.o
BIN = spoon
diff --git a/config.def.h b/config.def.h
t@@ -2,6 +2,7 @@ struct ent ents[] = {
/* reorder this if you want */
{ .fmt = "[%s] ", .read = mpdread },
{ .fmt = "[%s] ", .read = mixread },
+ { .fmt = "[%s] ", .read = loadread },
{ .fmt = "[%s] ", .read = cpuread },
{ .fmt = "[%s] ", .read = tempread },
{ .fmt = "%s ", .read = battread },
diff --git a/load.c b/load.c
t@@ -0,0 +1,14 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+loadread(char *buf, size_t len)
+{
+ double avgs[3];
+
+ if (getloadavg(avgs, 3) < 0)
+ return -1;
+ snprintf(buf, len, "%.2f %.2f %.2f",
+ avgs[0], avgs[1], avgs[2]);
+ return 0;
+}
diff --git a/spoon.c b/spoon.c
t@@ -9,6 +9,7 @@
int dummyread(char *buf, size_t len);
int mpdread(char *buf, size_t len);
+int loadread(char *buf, size_t len);
int cpuread(char *buf, size_t len);
int tempread(char *buf, size_t len);
int battread(char *buf, size_t len);
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.