summaryrefslogtreecommitdiff
path: root/src
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
parentf45554776ae470a8b8764f3fe5c7c400e76839d6 (diff)
downloadstatusbar-3e6a7d369b880413c1d9679fb7677e878fdbb45a.tar.gz
updatesHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/stmemory.c34
-rw-r--r--src/stmusic.c55
-rw-r--r--src/sttorrent.c37
3 files changed, 126 insertions, 0 deletions
diff --git a/src/stmemory.c b/src/stmemory.c
index 4f1435a..863d9fc 100644
--- a/src/stmemory.c
+++ b/src/stmemory.c
@@ -15,9 +15,41 @@
<https://www.gnu.org/licenses/>. */
#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 *termcmd[] = { term, "-e", "btop", NULL };
+
+ switch (button) {
+ case 1:
+ break;
+ case 2:
+ spawn(termcmd);
+ break;
+ case 3:
+ sendnotif("stmemory", " Memory module",
+ "- Shows Memory Used.\n- Click to show memory hogs.\n\
+- Middle click to open btop.");
+ break;
+ default: break;
+ }
+}
+
int
main(void)
{
@@ -25,6 +57,8 @@ main(void)
char line[256];
long total, free;
+ buttonhandler();
+
if (!(fp = fopen("/proc/meminfo", "r")))
die("failed to open: /proc/meminfo");
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) {
diff --git a/src/sttorrent.c b/src/sttorrent.c
index 3bd513f..b1a62d1 100644
--- a/src/sttorrent.c
+++ b/src/sttorrent.c
@@ -18,7 +18,42 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include "../lib/cjson/cJSON.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 *stig[] = { term, "-e", "stig", NULL };
+ const char *toggle[] = { "td-toggle", NULL };
+
+ switch (button) {
+ case 1:
+ spawn(stig);
+ break;
+ case 2:
+ spawn(toggle);
+ break;
+ case 3:
+ sendnotif("sttorrent", " Torrent module",
+ "- Left click to open stig.\n\
+- Middle click to toggle transmission.");
+ break;
+ default: break;
+ }
+}
struct MemoryStruct {
char *memory;
@@ -102,6 +137,8 @@ main(void)
struct curl_slist *headers = NULL;
const char *json = "{\"method\":\"torrent-get\",\"arguments\":{\"fields\":[\"status\", \"percentDone\"]}}";
+ buttonhandler();
+
curl_global_init(CURL_GLOBAL_ALL);
/* To get status from transmission we need to send
two CURL requests, first one to obtain session id. */