tAdd load average plugin - spoon - dwm status utility (2f30 fork)
(HTM) git clone git://src.adamsgaard.dk/spoon
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 96931ea266470a6a7b1f302837963dbb4351996e
(DIR) parent f5b1dc411d5c78695948f0c2aa44e3c8608a4428
(HTM) Author: sin <sin@2f30.org>
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(-)
---
(DIR) 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
(DIR) 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 },
(DIR) 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;
+}
(DIR) 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);