tAllow selecting the host/port for the mpd 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 36856fa7ba39356dcf456226797ff588a5733999
 (DIR) parent 474e42ea9414fa2cd257f8c5e3f75905d684d527
 (HTM) Author: sin <sin@2f30.org>
       Date:   Mon, 17 Oct 2016 17:09:27 +0100
       
       Allow selecting the host/port for the mpd plugin
       
       Diffstat:
         M Makefile                            |       2 +-
         M config.def.h                        |       2 +-
         M mpd.c                               |       4 +++-
         M spoon.c                             |       1 +
         A types.h                             |       4 ++++
       
       5 files changed, 10 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/Makefile b/Makefile
       t@@ -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
        
 (DIR) diff --git a/config.def.h b/config.def.h
       t@@ -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 },
 (DIR) diff --git a/mpd.c b/mpd.c
       t@@ -3,6 +3,7 @@
        
        #include <mpd/client.h>
        
       +#include "types.h"
        #include "util.h"
        
        int
       t@@ -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)
 (DIR) diff --git a/spoon.c b/spoon.c
       t@@ -24,6 +24,7 @@ struct ent {
                void *arg;
        };
        
       +#include "types.h"
        #include "config.h"
        
        int
 (DIR) diff --git a/types.h b/types.h
       t@@ -0,0 +1,4 @@
       +struct mpdarg {
       +        char *host;
       +        unsigned int port;
       +};