From 86044a6507dcef81564dc1a08b0d2d74034a8490 Mon Sep 17 00:00:00 2001 From: Jakub Trzeciak Date: Tue, 12 Sep 2023 08:46:18 +0200 Subject: Jptrzy's patches --- FUNDING.yml | 3 -- README.md | 48 ++--------------- config.h | 25 ++------- patches/dwmblocks-statuscmd-fork.diff | 77 --------------------------- patches/dwmblocks-statuscmd-signal.diff | 93 --------------------------------- 5 files changed, 7 insertions(+), 239 deletions(-) delete mode 100644 FUNDING.yml delete mode 100644 patches/dwmblocks-statuscmd-fork.diff delete mode 100644 patches/dwmblocks-statuscmd-signal.diff diff --git a/FUNDING.yml b/FUNDING.yml deleted file mode 100644 index f8e6076..0000000 --- a/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -github: lukesmithxyz -custom: ["https://lukesmith.xyz/donate", "https://paypal.me/lukemsmith", "https://lukesmith.xyz/crypto"] -patreon: lukesmith diff --git a/README.md b/README.md index 7d21e30..6e134ea 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,4 @@ -# dwmblocks - -Modular status bar for dwm written in c. - -# Modifying blocks - -The statusbar is made from text output from commandline programs. Blocks are -added and removed by editing the config.h file. - -# Luke's build - -I have dwmblocks read my preexisting scripts -[here in my dotfiles repo](https://github.com/LukeSmithxyz/voidrice/tree/master/.local/bin/statusbar). -So if you want my build out of the box, download those and put them in your -`$PATH`. I do this to avoid redundancy in LARBS, both i3 and dwm use the same -statusbar scripts. - -# Signaling changes - -Most statusbars constantly rerun every script every several seconds to update. -This is an option here, but a superior choice is giving your module a signal -that you can signal to it to update on a relevant event, rather than having it -rerun idly. - -For example, the audio module has the update signal 10 by default. Thus, -running `pkill -RTMIN+10 dwmblocks` will update it. - -You can also run `kill -44 $(pidof dwmblocks)` which will have the same effect, -but is faster. Just add 34 to your typical signal number. - -My volume module *never* updates on its own, instead I have this command run -along side my volume shortcuts in dwm to only update it when relevant. - -Note that all modules must have different signal numbers. - -# Clickable modules - -Like i3blocks, this build allows you to build in additional actions into your -scripts in response to click events. See the above linked scripts for examples -of this using the `$BLOCK_BUTTON` variable. - -For this feature to work, you need the appropriate patch in dwm as well. See -[here](https://dwm.suckless.org/patches/statuscmd/). -Credit for those patches goes to Daniel Bylinka (daniel.bylinka@gmail.com). +# Jptrzy's dwmblocks +# Patches +* signal +* ... - I don't remember 🤣 diff --git a/config.h b/config.h index f71c4a5..6efe65a 100644 --- a/config.h +++ b/config.h @@ -1,33 +1,14 @@ //Modify this file to change what commands output to your statusbar, and recompile using the make command. static const Block blocks[] = { /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ - /* {"⌨", "sb-kbselect", 0, 30}, */ - {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, - {"", "sb-tasks", 10, 26}, - /* {"", "sb-music", 0, 11}, */ - {"", "sb-pacpackages", 0, 8}, - {"", "sb-news", 0, 6}, - /* {"", "sb-price xmr Monero 🔒 24", 9000, 24}, */ - /* {"", "sb-price eth Ethereum 🍸 23", 9000, 23}, */ - /* {"", "sb-price btc Bitcoin 💰 21", 9000, 21}, */ - {"", "sb-torrent", 20, 7}, - /* {"", "sb-memory", 10, 14}, */ - /* {"", "sb-cpu", 10, 18}, */ - /* {"", "sb-moonphase", 18000, 17}, */ - {"", "sb-doppler", 0, 13}, - {"", "sb-forecast", 18000, 5}, - {"", "sb-mailbox", 180, 12}, - {"", "sb-nettraf", 1, 16}, - {"", "sb-volume", 0, 10}, + {"", "sb-netuse", 1, 16}, + {"", "sb-drive", 0, 30}, {"", "sb-battery", 5, 3}, {"", "sb-clock", 60, 1}, - {"", "sb-internet", 5, 4}, - /* {"", "sb-iplocate", 0, 27}, */ - {"", "sb-help-icon", 0, 15}, }; //Sets delimiter between status commands. NULL character ('\0') means no delimiter. -static char *delim = " "; +static char *delim = " | "; // Have dwmblocks automatically recompile and run when you edit this file in // vim with the following line in your vimrc/init.vim: diff --git a/patches/dwmblocks-statuscmd-fork.diff b/patches/dwmblocks-statuscmd-fork.diff deleted file mode 100644 index 1ae7d7a..0000000 --- a/patches/dwmblocks-statuscmd-fork.diff +++ /dev/null @@ -1,77 +0,0 @@ -diff --git a/dwmblocks.c b/dwmblocks.c -index 7d7a564..e2c5dd0 100644 ---- a/dwmblocks.c -+++ b/dwmblocks.c -@@ -34,8 +34,6 @@ static int screen; - static Window root; - static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; - static char statusstr[2][256]; --static char exportstring[CMDLENGTH + 22] = "export BLOCK_BUTTON=-;"; --static int button = 0; - static int statusContinue = 1; - static void (*writestatus) () = setroot; - -@@ -55,21 +53,8 @@ void getcmd(const Block *block, char *output) - output[0] = block->signal; - output++; - } -- char* cmd; -- FILE *cmdf; -- if (button) -- { -- cmd = strcat(exportstring, block->command); -- cmd[20] = '0' + button; -- button = 0; -- cmdf = popen(cmd,"r"); -- cmd[22] = '\0'; -- } -- else -- { -- cmd = block->command; -- cmdf = popen(cmd,"r"); -- } -+ char *cmd = block->command; -+ FILE *cmdf = popen(cmd,"r"); - if (!cmdf) - return; - fgets(output, CMDLENGTH, cmdf); -@@ -117,6 +102,7 @@ void setupsignals() - sa.sa_sigaction = buttonhandler; - sa.sa_flags = SA_SIGINFO; - sigaction(SIGUSR1, &sa, NULL); -+ signal(SIGCHLD, SIG_IGN); - - } - #endif -@@ -179,9 +165,29 @@ void sighandler(int signum) - - void buttonhandler(int sig, siginfo_t *si, void *ucontext) - { -- button = si->si_value.sival_int & 0xff; -- getsigcmds(si->si_value.sival_int >> 8); -+ int button = si->si_value.sival_int & 0xff; -+ sig = si->si_value.sival_int >> 8; -+ getsigcmds(sig); - writestatus(); -+ if (fork() == 0) -+ { -+ static char exportstring[CMDLENGTH + 22] = "export BLOCK_BUTTON=-;"; -+ const Block *current; -+ int i; -+ for (i = 0; i < LENGTH(blocks); i++) -+ { -+ current = blocks + i; -+ if (current->signal == sig) -+ break; -+ } -+ char *cmd = strcat(exportstring, blocks[i].command); -+ cmd[20] = '0' + button; -+ char *command[] = { "/bin/sh", "-c", cmd, NULL }; -+ setsid(); -+ execvp(command[0], command); -+ exit(EXIT_SUCCESS); -+ cmd[22] = '\0'; -+ } - } - - #endif diff --git a/patches/dwmblocks-statuscmd-signal.diff b/patches/dwmblocks-statuscmd-signal.diff deleted file mode 100644 index c2092e7..0000000 --- a/patches/dwmblocks-statuscmd-signal.diff +++ /dev/null @@ -1,93 +0,0 @@ -diff --git a/dwmblocks.c b/dwmblocks.c -index 88bdfb0..7bd14df 100644 ---- a/dwmblocks.c -+++ b/dwmblocks.c -@@ -14,6 +14,7 @@ typedef struct { - unsigned int signal; - } Block; - void sighandler(int num); -+void buttonhandler(int sig, siginfo_t *si, void *ucontext); - void replace(char *str, char old, char new); - void getcmds(int time); - #ifndef __OpenBSD__ -@@ -34,6 +35,8 @@ static int screen; - static Window root; - static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; - static char statusstr[2][256]; -+static char exportstring[CMDLENGTH + 16] = "export BUTTON=-;"; -+static int button = 0; - static int statusContinue = 1; - static void (*writestatus) () = setroot; - -@@ -48,16 +51,34 @@ void replace(char *str, char old, char new) - //opens process *cmd and stores output in *output - void getcmd(const Block *block, char *output) - { -+ if (block->signal) -+ { -+ output[0] = block->signal; -+ output++; -+ } - strcpy(output, block->icon); -- char *cmd = block->command; -- FILE *cmdf = popen(cmd,"r"); -+ char* cmd; -+ FILE *cmdf; -+ if (button) -+ { -+ cmd = strcat(exportstring, block->command); -+ cmd[14] = '0' + button; -+ button = 0; -+ cmdf = popen(cmd,"r"); -+ cmd[16] = '\0'; -+ } -+ else -+ { -+ cmd = block->command; -+ cmdf = popen(cmd,"r"); -+ } - if (!cmdf) - return; - char c; - int i = strlen(block->icon); - fgets(output+i, CMDLENGTH-i, cmdf); - i = strlen(output); -- if (delim != '\0' && --i) -+ if (delim != '\0' && i) - output[i++] = delim; - output[i++] = '\0'; - pclose(cmdf); -@@ -88,11 +106,18 @@ void getsigcmds(int signal) - - void setupsignals() - { -+ struct sigaction sa; - for(int i = 0; i < LENGTH(blocks); i++) - { - if (blocks[i].signal > 0) -+ { - signal(SIGRTMIN+blocks[i].signal, sighandler); -+ sigaddset(&sa.sa_mask, SIGRTMIN+blocks[i].signal); -+ } - } -+ sa.sa_sigaction = buttonhandler; -+ sa.sa_flags = SA_SIGINFO; -+ sigaction(SIGUSR1, &sa, NULL); - - } - #endif -@@ -152,6 +177,14 @@ void sighandler(int signum) - getsigcmds(signum-SIGRTMIN); - writestatus(); - } -+ -+void buttonhandler(int sig, siginfo_t *si, void *ucontext) -+{ -+ button = si->si_value.sival_int & 0xff; -+ getsigcmds(si->si_value.sival_int >> 8); -+ writestatus(); -+} -+ - #endif - - void termhandler(int signum) -- cgit v1.2.3