diff options
author | awy <awy@awy.one> | 2025-09-13 12:59:29 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-09-13 12:59:29 +0300 |
commit | 3e6a7d369b880413c1d9679fb7677e878fdbb45a (patch) | |
tree | 03e3e1163335808816fe924cb329beb80eceb609 /src/sttorrent.c | |
parent | f45554776ae470a8b8764f3fe5c7c400e76839d6 (diff) | |
download | statusbar-3e6a7d369b880413c1d9679fb7677e878fdbb45a.tar.gz |
Diffstat (limited to 'src/sttorrent.c')
-rw-r--r-- | src/sttorrent.c | 37 |
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. */ |