summaryrefslogtreecommitdiff
path: root/src/stmusic.c
diff options
context:
space:
mode:
authorawy <awy@awy.one>2025-09-13 12:59:29 +0300
committerawy <awy@awy.one>2025-09-13 12:59:29 +0300
commit3e6a7d369b880413c1d9679fb7677e878fdbb45a (patch)
tree03e3e1163335808816fe924cb329beb80eceb609 /src/stmusic.c
parentf45554776ae470a8b8764f3fe5c7c400e76839d6 (diff)
downloadstatusbar-3e6a7d369b880413c1d9679fb7677e878fdbb45a.tar.gz
updatesHEADmaster
Diffstat (limited to 'src/stmusic.c')
-rw-r--r--src/stmusic.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/stmusic.c b/src/stmusic.c
index 46d7059..ac81de1 100644
--- a/src/stmusic.c
+++ b/src/stmusic.c
@@ -16,6 +16,59 @@
#include <mpd/client.h>
#include <stdio.h>
+#include <stdlib.h>
+
+#include "../lib/util.h"
+
+void
+buttonhandler()
+{
+ char *term;
+ char *env;
+ int button;
+
+ button = 0;
+ if ((env = getenv("BLOCK_BUTTON")))
+ button = getbtnint(env);
+
+ if (!(term = getenv("TERMINAL")))
+ term = "footclient";
+
+ const char *rmpc[] = { term, "-e", "rmpc", NULL };
+ const char *toggle[] = { "rmpc", "togglepause", NULL };
+ const char *prev[] = { "rmpc", "prev", NULL };
+ const char *next[] = { "rmpc", "next", NULL };
+
+ switch (button) {
+ case 1:
+ spawn(rmpc);
+ break;
+ case 2:
+ spawn(toggle);
+ break;
+ case 3:
+ sendnotif("stmusic", " Music module",
+ "- Shows mpd song playing.\n\
+-  paused.\n\
+-  repeat mode.\n\
+-  shuffle mode.\n\
+- 󰮯 consume mode.\n\
+- 󰮯 󰇊 consume oneshot mode.\n\
+- 󰎤 single mode.\n\
+- 󰇊 single oneshot mode.\n\
+- Left click opens rmpc.\n\
+- Middle click pauses.\n\
+- Scroll changes track.");
+ break;
+ case 4:
+ spawn(prev);
+ break;
+ case 5:
+ spawn(next);
+ break;
+ default: break;
+ }
+}
int
main(void)
@@ -24,6 +77,8 @@ main(void)
struct mpd_status *status;
struct mpd_song *song;
+ buttonhandler();
+
/* Connect to MPD (default: localhost:6600) */
conn = mpd_connection_new(NULL, 0, 30000);
if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS) {