diff -Naur dwmbase/config.def.h dwmfork/config.def.h
--- dwmbase/config.def.h 2015-11-08 23:39:37.000000000 +0100
+++ dwmfork/config.def.h 2018-02-19 09:29:10.686311679 +0100
@@ -1,5 +1,5 @@
/* See LICENSE file for copyright and license details. */
-
+#include <X11/XF86keysym.h> //needed for X11 media keys, remove if unnecessary
/* appearance */
static const char *fonts[] = {
"monospace:size=10"
@@ -61,6 +61,9 @@
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
+ { 0, XF86XK_AudioPlay, mpdcontrol, {.i = 0 } },
+ { 0, XF86XK_AudioPrev, mpdcontrol, {.i = -1 } },
+ { 0, XF86XK_AudioNext, mpdcontrol, {.i = +1 } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
diff -Naur dwmbase/config.mk dwmfork/config.mk
--- dwmbase/config.mk 2015-11-08 23:39:37.000000000 +0100
+++ dwmfork/config.mk 2018-02-19 09:30:08.112973336 +0100
@@ -22,7 +22,7 @@
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC}
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
+LIBS = -L${X11LIB} -lmpdclient -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
# flags
CPPFLAGS = -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff -Naur dwmbase/dwm.c dwmfork/dwm.c
--- dwmbase/dwm.c 2015-11-08 23:39:37.000000000 +0100
+++ dwmfork/dwm.c 2018-02-19 09:32:28.099627791 +0100
@@ -40,6 +40,9 @@
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
#include <X11/Xft/Xft.h>
+#include <mpd/connection.h>
+#include <mpd/player.h>
+#include <mpd/status.h>
#include "drw.h"
#include "util.h"
@@ -184,6 +187,7 @@
static void monocle(Monitor *m);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
+static void mpdcontrol(const Arg *arg);
static Client *nexttiled(Client *c);
static void pop(Client *);
static void propertynotify(XEvent *e);
@@ -1209,6 +1213,40 @@
}
}
+void
+mpdcontrol(const Arg *arg)
+{
+ struct mpd_connection *connection;
+ connection = mpd_connection_new(NULL,0,1000);
+ if(mpd_connection_get_error(connection)!=MPD_ERROR_SUCCESS)
+ {
+ mpd_connection_free(connection);
+ return;
+ }
+ switch(arg->i)
+ {
+ case -1:
+ mpd_send_previous(connection);
+ break;
+ case 0:
+ ;
+ struct mpd_status *stat;
+ stat = mpd_status_begin();
+ mpd_send_status(connection);
+ stat = mpd_recv_status(connection);
+ if(mpd_status_get_state(stat)==MPD_STATE_STOP)
+ mpd_send_play(connection);
+ else
+ mpd_send_toggle_pause(connection);
+ mpd_status_free(stat);
+ break;
+ case 1:
+ mpd_send_next(connection);
+ break;
+ }
+ mpd_connection_free(connection);
+}
+
Client *
nexttiled(Client *c)
{