summaryrefslogtreecommitdiff
path: root/src/sttorrent.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/sttorrent.c
parentf45554776ae470a8b8764f3fe5c7c400e76839d6 (diff)
downloadstatusbar-3e6a7d369b880413c1d9679fb7677e878fdbb45a.tar.gz
updatesHEADmaster
Diffstat (limited to 'src/sttorrent.c')
-rw-r--r--src/sttorrent.c37
1 files changed, 37 insertions, 0 deletions
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. */