commit 36856fa7ba39356dcf456226797ff588a5733999
parent 474e42ea9414fa2cd257f8c5e3f75905d684d527
Author: sin <sin@2f30.org>
Date: Mon, 17 Oct 2016 17:09:27 +0100
Allow selecting the host/port for the mpd plugin
Diffstat:
5 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -5,7 +5,7 @@ SRC = spoon.c batt.c wifi.c cpu.c temp.c mix.c date.c load.c\
OBJ = spoon.o batt.o wifi.o cpu.o temp.o mix.o date.o load.o\
strlcpy.o strlcat.o stub.o
BIN = spoon
-DISTFILES = $(SRC) util.h config.def.h Makefile LICENSE configure
+DISTFILES = $(SRC) types.h util.h config.def.h Makefile LICENSE configure
include config.mk
diff --git a/config.def.h b/config.def.h
@@ -3,7 +3,7 @@ int delay = 1;
struct ent ents[] = {
/* reorder/remove these as you see fit */
- { .fmt = "[%s] ", .read = mpdread, .arg = NULL },
+ { .fmt = "[%s] ", .read = mpdread, .arg = &(struct mpdarg){ .host = NULL, .port = 0 } },
{ .fmt = "[%s] ", .read = mixread, .arg = NULL },
{ .fmt = "[%s] ", .read = loadread, .arg = NULL },
{ .fmt = "[%s] ", .read = cpuread, .arg = NULL },
diff --git a/mpd.c b/mpd.c
@@ -3,6 +3,7 @@
#include <mpd/client.h>
+#include "types.h"
#include "util.h"
int
@@ -11,9 +12,10 @@ mpdread(void *arg, char *buf, size_t len)
static struct mpd_connection *conn;
struct mpd_song *song;
const char *artist, *title, *name;
+ struct mpdarg *mpdarg = arg;
if (conn == NULL) {
- conn = mpd_connection_new(NULL, 0, 0);
+ conn = mpd_connection_new(mpdarg->host, mpdarg->port, 0);
if (conn == NULL)
return -1;
if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS)
diff --git a/spoon.c b/spoon.c
@@ -24,6 +24,7 @@ struct ent {
void *arg;
};
+#include "types.h"
#include "config.h"
int
diff --git a/types.h b/types.h
@@ -0,0 +1,4 @@
+struct mpdarg {
+ char *host;
+ unsigned int port;
+};