Introduction
Introduction Statistics Contact Development Disclaimer Help
tAdd support for passing an argument to a plugin - spoon - dwm status utility (…
git clone git://src.adamsgaard.dk/spoon
Log
Files
Refs
LICENSE
---
commit a1183652b40ef2d2b72ee5a84e72ed499c9544f8
parent 013798f7c8c22eec779f63fbf2558092b29d2c0d
Author: sin <[email protected]>
Date: Mon, 17 Oct 2016 16:43:19 +0100
Add support for passing an argument to a plugin
Diffstat:
M batt.c | 4 ++--
M config.def.h | 18 +++++++++---------
M cpu.c | 2 +-
M date.c | 6 ++----
M load.c | 2 +-
M mix.c | 2 +-
M mpd.c | 2 +-
M spoon.c | 27 ++++++++++++++-------------
M stub.c | 14 +++++++-------
M temp.c | 4 ++--
M wifi.c | 2 +-
M xkblayout.c | 2 +-
12 files changed, 42 insertions(+), 43 deletions(-)
---
diff --git a/batt.c b/batt.c
t@@ -30,7 +30,7 @@ battprint(char *buf, size_t len, int acon , int life)
#include <machine/apmvar.h>
int
-battread(char *buf, size_t len)
+battread(void *arg, char *buf, size_t len)
{
struct apm_power_info info;
int ret, fd;
t@@ -52,7 +52,7 @@ battread(char *buf, size_t len)
}
#elif __linux__
int
-battread(char *buf, size_t len)
+battread(void *arg, char *buf, size_t len)
{
FILE *fp;
int acon;
diff --git a/config.def.h b/config.def.h
t@@ -5,13 +5,13 @@ char timeformat[] = "%a %d %b %Y %H:%M %Z";
struct ent ents[] = {
/* reorder/remove these as you see fit */
- { .fmt = "[%s] ", .read = mpdread },
- { .fmt = "[%s] ", .read = mixread },
- { .fmt = "[%s] ", .read = loadread },
- { .fmt = "[%s] ", .read = cpuread },
- { .fmt = "[%s] ", .read = tempread },
- { .fmt = "%s ", .read = battread },
- { .fmt = "%s ", .read = wifiread },
- { .fmt = "[%s] ", .read = xkblayoutread },
- { .fmt = "%s", .read = dateread },
+ { .fmt = "[%s] ", .read = mpdread, .arg = NULL },
+ { .fmt = "[%s] ", .read = mixread, .arg = NULL },
+ { .fmt = "[%s] ", .read = loadread, .arg = NULL },
+ { .fmt = "[%s] ", .read = cpuread, .arg = NULL },
+ { .fmt = "[%s] ", .read = tempread, .arg = NULL },
+ { .fmt = "%s ", .read = battread, .arg = NULL },
+ { .fmt = "%s ", .read = wifiread, .arg = NULL },
+ { .fmt = "[%s] ", .read = xkblayoutread, .arg = NULL },
+ { .fmt = "%s", .read = dateread, .arg = (char []…
};
diff --git a/cpu.c b/cpu.c
t@@ -4,7 +4,7 @@
#include <sys/sysctl.h>
int
-cpuread(char *buf, size_t len)
+cpuread(void *arg, char *buf, size_t len)
{
int mib[2], cpuspeed;
size_t sz;
diff --git a/date.c b/date.c
t@@ -3,10 +3,8 @@
#include <stdio.h>
#include <time.h>
-extern char timeformat[];
-
int
-dateread(char *buf, size_t len)
+dateread(void *arg, char *buf, size_t len)
{
struct tm *now;
time_t t;
t@@ -15,6 +13,6 @@ dateread(char *buf, size_t len)
now = localtime(&t);
if (now == NULL)
return -1;
- strftime(buf, len, timeformat, now);
+ strftime(buf, len, arg, now);
return 0;
}
diff --git a/load.c b/load.c
t@@ -2,7 +2,7 @@
#include <stdio.h>
int
-loadread(char *buf, size_t len)
+loadread(void *arg, char *buf, size_t len)
{
double avgs[3];
diff --git a/mix.c b/mix.c
t@@ -9,7 +9,7 @@
#include <string.h>
int
-mixread(char *buf, size_t len)
+mixread(void *arg, char *buf, size_t len)
{
mixer_devinfo_t dinfo;
mixer_ctrl_t mctl;
diff --git a/mpd.c b/mpd.c
t@@ -6,7 +6,7 @@
#include "util.h"
int
-mpdread(char *buf, size_t len)
+mpdread(void *arg, char *buf, size_t len)
{
static struct mpd_connection *conn;
struct mpd_song *song;
diff --git a/spoon.c b/spoon.c
t@@ -6,26 +6,27 @@
#define LEN(x) (sizeof (x) / sizeof *(x))
-int battread(char *, size_t);
-int cpuread(char *, size_t);
-int dateread(char *, size_t);
-int dummyread(char *, size_t);
-int loadread(char *, size_t);
-int mixread(char *, size_t);
-int mpdread(char *, size_t);
-int tempread(char *, size_t);
-int wifiread(char *, size_t);
-int xkblayoutread(char *, size_t);
+int battread(void *, char *, size_t);
+int cpuread(void *, char *, size_t);
+int dateread(void *, char *, size_t);
+int dummyread(void *, char *, size_t);
+int loadread(void *, char *, size_t);
+int mixread(void *, char *, size_t);
+int mpdread(void *, char *, size_t);
+int tempread(void *, char *, size_t);
+int wifiread(void *, char *, size_t);
+int xkblayoutread(void *, char *, size_t);
struct ent {
char *fmt;
- int (*read)(char *, size_t);
+ int (*read)(void *, char *, size_t);
+ void *arg;
};
#include "config.h"
int
-dummyread(char *buf, size_t len)
+dummyread(void *arg, char *buf, size_t len)
{
buf[0] = '\0';
return 0;
t@@ -43,7 +44,7 @@ entcat(char *line, size_t len)
e = line + len;
for (i = 0; i < LEN(ents); i++) {
ent = &ents[i];
- ret = ent->read(buf, sizeof(buf));
+ ret = ent->read(ent->arg, buf, sizeof(buf));
if (ret == 0 && s < e)
s += snprintf(s, e - s, ent->fmt, buf);
}
diff --git a/stub.c b/stub.c
t@@ -2,49 +2,49 @@
#pragma weak battread
int
-battread(char *buf, size_t len)
+battread(void *arg, char *buf, size_t len)
{
return -1;
}
#pragma weak cpuread
int
-cpuread(char *buf, size_t len)
+cpuread(void *arg, char *buf, size_t len)
{
return -1;
}
#pragma weak mixread
int
-mixread(char *buf, size_t len)
+mixread(void *arg, char *buf, size_t len)
{
return -1;
}
#pragma weak mpdread
int
-mpdread(char *buf, size_t len)
+mpdread(void *arg, char *buf, size_t len)
{
return -1;
}
#pragma weak tempread
int
-tempread(char *buf, size_t len)
+tempread(void *arg, char *buf, size_t len)
{
return -1;
}
#pragma weak wifiread
int
-wifiread(char *buf, size_t len)
+wifiread(void *arg, char *buf, size_t len)
{
return -1;
}
#pragma weak xkblayoutread
int
-xkblayoutread(char *buf, size_t len)
+xkblayoutread(void *arg, char *buf, size_t len)
{
return -1;
}
diff --git a/temp.c b/temp.c
t@@ -7,7 +7,7 @@
#include <sys/sensors.h>
int
-tempread(char *buf, size_t len)
+tempread(void *arg, char *buf, size_t len)
{
int mib[5];
struct sensor temp;
t@@ -26,7 +26,7 @@ tempread(char *buf, size_t len)
}
#elif __linux__
int
-tempread(char *buf, size_t len)
+tempread(void *arg, char *buf, size_t len)
{
FILE *fp;
int temp;
diff --git a/wifi.c b/wifi.c
t@@ -35,7 +35,7 @@ wifiprint(char *buf, size_t len, int quality)
#include <unistd.h>
int
-wifiread(char *buf, size_t len)
+wifiread(void *arg, char *buf, size_t len)
{
struct ifaddrs *ifa, *ifas;
struct ifmediareq ifmr;
diff --git a/xkblayout.c b/xkblayout.c
t@@ -10,7 +10,7 @@
#include "util.h"
int
-xkblayoutread(char *buf, size_t len)
+xkblayoutread(void *arg, char *buf, size_t len)
{
Display *dpy;
XkbStateRec state;
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.