From 3e6a7d369b880413c1d9679fb7677e878fdbb45a Mon Sep 17 00:00:00 2001 From: awy Date: Sat, 13 Sep 2025 12:59:29 +0300 Subject: updates --- src/sttorrent.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/sttorrent.c') 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 #include #include + #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. */ -- cgit v1.2.3