spoon

set dwm status
git clone git://git.2f30.org/spoon
Log | Files | Refs | LICENSE

commit 96931ea266470a6a7b1f302837963dbb4351996e
parent f5b1dc411d5c78695948f0c2aa44e3c8608a4428
Author: sin <sin@2f30.org>
Date:   Thu, 13 Oct 2016 10:42:31 +0100

Add load average plugin

Diffstat:
MMakefile | 6+++---
Mconfig.def.h | 1+
Aload.c | 14++++++++++++++
Mspoon.c | 1+
4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -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 @@ -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 @@ -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 @@ -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);