From f67807d3483aef73e9d860a38e86a0c019ba7ae1 Mon Sep 17 00:00:00 2001 From: ryanm0 Date: Tue, 4 Aug 2020 23:16:36 -1000 Subject: [PATCH 01/13] Makefile: fix "output" target name Without the right target name, make will rebuild the target (dwmblocks) every time make is run, even if the source files haven't changed. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c2c3c6b..efd2104 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,13 @@ PREFIX = /usr/local -output: dwmblocks.o +dwmblocks: dwmblocks.o gcc dwmblocks.o -lX11 -o dwmblocks dwmblocks.o: dwmblocks.c config.h gcc -c -lX11 dwmblocks.c clean: rm -f *.o *.gch dwmblocks -install: output +install: dwmblocks mkdir -p $(DESTDIR)$(PREFIX)/bin cp -f dwmblocks $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/dwmblocks From 841a60783024d882e3dad3713f08712a9deae09e Mon Sep 17 00:00:00 2001 From: ryanm0 Date: Tue, 4 Aug 2020 23:19:06 -1000 Subject: [PATCH 02/13] Makefile: use $(CC) instead of hardcoding gcc --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index efd2104..5cfbb5a 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ .POSIX: PREFIX = /usr/local +CC = gcc dwmblocks: dwmblocks.o - gcc dwmblocks.o -lX11 -o dwmblocks + $(CC) dwmblocks.o -lX11 -o dwmblocks dwmblocks.o: dwmblocks.c config.h - gcc -c -lX11 dwmblocks.c + $(CC) -c dwmblocks.c clean: rm -f *.o *.gch dwmblocks install: dwmblocks From 7524ccd1e5eb69ab177cb7f0bc4044994464be6e Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 28 Aug 2020 19:27:12 -0400 Subject: [PATCH 03/13] update and fork fix --- dwmblocks.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dwmblocks.c b/dwmblocks.c index d135a7d..68267d7 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -193,6 +193,7 @@ void sighandler(int signum) void buttonhandler(int sig, siginfo_t *si, void *ucontext) { char button[2] = {'0' + si->si_value.sival_int & 0xff, '\0'}; + pid_t process_id = getpid(); sig = si->si_value.sival_int >> 8; if (fork() == 0) { @@ -203,14 +204,14 @@ void buttonhandler(int sig, siginfo_t *si, void *ucontext) if (current->signal == sig) break; } - char *command[] = { "/bin/sh", "-c", current->command, NULL }; + char shcmd[1024]; + sprintf(shcmd,"%s && kill -%d %d",current->command, current->signal+34,process_id); + char *command[] = { "/bin/sh", "-c", shcmd, NULL }; setenv("BLOCK_BUTTON", button, 1); setsid(); execvp(command[0], command); exit(EXIT_SUCCESS); } - getsigcmds(sig); - writestatus(); } #endif From 7bd5e64364eefb5adfafa2cabaad3a1e74199df8 Mon Sep 17 00:00:00 2001 From: danielrainer <34983953+danielrainer@users.noreply.github.com> Date: Wed, 9 Sep 2020 20:31:33 +0200 Subject: [PATCH 04/13] Change spelling in comment Change the word "delimeter" to "delimiter" --- config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.h b/config.h index 6106bba..cc9281b 100644 --- a/config.h +++ b/config.h @@ -23,7 +23,7 @@ static const Block blocks[] = { {"", "help-icon", 0, 15}, }; -//sets delimeter between status commands. NULL character ('\0') means no delimeter. +//Sets delimiter between status commands. NULL character ('\0') means no delimiter. static char *delim = " "; // Have dwmblocks automatically recompile and run when you edit this file in From 791a837fac7089cd70d9c950e93227b71a134678 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sun, 11 Oct 2020 15:18:55 -0400 Subject: [PATCH 05/13] weather -> forceast; different defaults --- config.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/config.h b/config.h index 6106bba..a45c053 100644 --- a/config.h +++ b/config.h @@ -1,21 +1,25 @@ //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*/ + /* {"⌨", "kbselect", 0, 30}, */ {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, - /* {"", "music", 0, 11},*/ + /* {"", "music", 0, 11}, */ {"", "pacpackages", 0, 8}, {"", "news", 0, 6}, /* {"", "crypto", 0, 13}, */ - /* {"", "price bat \"Basic Attention Token\" 🦁", 0, 20}, */ - /* {"", "price btc Bitcoin 💰", 0, 21}, */ - /* {"", "price lbc \"LBRY Token\" 📚", 0, 22}, */ - {"", "torrent", 20, 7}, + /* {"", "price lbc \"LBRY Token\" 📚", 9000, 22}, */ + /* {"", "price bat \"Basic Attention Token\" 🦁", 9000, 20}, */ + /* {"", "price link \"Chainlink\" 🔗", 300, 25}, */ + /* {"", "price xmr \"Monero\" 🔒", 9000, 24}, */ + /* {"", "price eth Ethereum 🍸", 9000, 23}, */ + /* {"", "price btc Bitcoin 💰", 9000, 21}, */ + /* {"", "torrent", 20, 7}, */ /* {"", "memory", 10, 14}, */ /* {"", "cpu", 10, 18}, */ /* {"", "moonphase", 18000, 17}, */ - {"", "weather", 18000, 5}, + {"", "forecast", 18000, 5}, {"", "mailbox", 180, 12}, - /* {"", "nettraf", 1, 16}, */ + {"", "nettraf", 1, 16}, {"", "volume", 0, 10}, {"", "battery", 5, 3}, {"", "clock", 60, 1}, From fd15bc9b95da2e352649b02e5b36cf2975ddf1fe Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 25 Dec 2020 08:03:23 -0500 Subject: [PATCH 06/13] scripts prefixed with sb- to avoid conflicts rename scripts or update voidrice repo --- config.h | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/config.h b/config.h index 18b287b..34f4bfe 100644 --- a/config.h +++ b/config.h @@ -3,28 +3,29 @@ static const Block blocks[] = { /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ /* {"⌨", "kbselect", 0, 30}, */ {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, - /* {"", "music", 0, 11}, */ - {"", "pacpackages", 0, 8}, - {"", "news", 0, 6}, - /* {"", "crypto", 0, 13}, */ - /* {"", "price lbc \"LBRY Token\" 📚", 9000, 22}, */ - /* {"", "price bat \"Basic Attention Token\" 🦁", 9000, 20}, */ - /* {"", "price link \"Chainlink\" 🔗", 300, 25}, */ - /* {"", "price xmr \"Monero\" 🔒", 9000, 24}, */ - /* {"", "price eth Ethereum 🍸", 9000, 23}, */ - /* {"", "price btc Bitcoin 💰", 9000, 21}, */ - /* {"", "torrent", 20, 7}, */ - /* {"", "memory", 10, 14}, */ - /* {"", "cpu", 10, 18}, */ - /* {"", "moonphase", 18000, 17}, */ - {"", "forecast", 18000, 5}, - {"", "mailbox", 180, 12}, - {"", "nettraf", 1, 16}, - {"", "volume", 0, 10}, - {"", "battery", 5, 3}, - {"", "clock", 60, 1}, - {"", "internet", 5, 4}, - {"", "help-icon", 0, 15}, + {"", "sb-tasks", 10, 26}, + {"", "sb-music", 0, 11}, + {"", "sb-pacpackages", 0, 8}, + {"", "sb-news", 0, 6}, + /* {"", "sb-crypto", 0, 13}, */ + /* {"", "sb-price lbc \"LBRY Token\" 📚", 9000, 22}, */ + /* {"", "sb-price bat \"Basic Attention Token\" 🦁", 9000, 20}, */ + /* {"", "sb-price link \"Chainlink\" 🔗", 300, 25}, */ + /* {"", "sb-price xmr \"Monero\" 🔒", 9000, 24}, */ + /* {"", "sb-price eth Ethereum 🍸", 9000, 23}, */ + /* {"", "sb-price btc Bitcoin 💰", 9000, 21}, */ + {"", "sb-torrent", 20, 7}, + /* {"", "sb-memory", 10, 14}, */ + /* {"", "sb-cpu", 10, 18}, */ + /* {"", "sb-moonphase", 18000, 17}, */ + {"", "sb-forecast", 18000, 5}, + {"", "sb-mailbox", 180, 12}, + {"", "sb-nettraf", 1, 16}, + {"", "sb-volume", 0, 10}, + {"", "sb-battery", 5, 3}, + {"", "sb-clock", 60, 1}, + {"", "sb-internet", 5, 4}, + {"", "sb-help-icon", 0, 15}, }; //Sets delimiter between status commands. NULL character ('\0') means no delimiter. From 4c13564c8385252f52dea543cad13e3c57612cac Mon Sep 17 00:00:00 2001 From: Daniel Rose Date: Mon, 28 Dec 2020 15:17:14 -0500 Subject: [PATCH 07/13] Change KBSelect Program To Include SB Prefix --- config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.h b/config.h index 34f4bfe..eaf2dbe 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ //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*/ - /* {"⌨", "kbselect", 0, 30}, */ + /* {"⌨", "sb-kbselect", 0, 30}, */ {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, {"", "sb-tasks", 10, 26}, {"", "sb-music", 0, 11}, From 747067e64e64c2723c5a71f518498c2162195d45 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 2 Feb 2021 15:19:03 -0500 Subject: [PATCH 08/13] fix #61 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b6a4685..2b40431 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ Note that if you signal an unexpected signal to dwmblocks, it will probably crash. So if you disable a module, remember to also disable any cronjobs or other scripts that might signal to that module. +Note also that all modules must have different signal numbers. + # Clickable modules Like i3blocks, this build allows you to build in additional actions into your From e7b3d9d9d6ca1ac2e8efc7f009bd0ed9ba5f18dc Mon Sep 17 00:00:00 2001 From: Federico Ciuffardi Date: Sun, 7 Feb 2021 03:57:01 -0300 Subject: [PATCH 09/13] Mitigates disapearing blocks on fast mouse interaction --- dwmblocks.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/dwmblocks.c b/dwmblocks.c index 68267d7..12648ef 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -13,6 +13,7 @@ typedef struct { unsigned int interval; unsigned int signal; } Block; +char** last_updates; void sighandler(int num); void buttonhandler(int sig, siginfo_t *si, void *ucontext); void replace(char *str, char old, char new); @@ -61,7 +62,7 @@ void remove_all(char *str, char to_remove) { } //opens process *cmd and stores output in *output -void getcmd(const Block *block, char *output) +void getcmd(const Block *block, char* last_update , char *output) { if (block->signal) { @@ -77,10 +78,15 @@ void getcmd(const Block *block, char *output) int i = strlen(block->icon); fgets(output+i, CMDLENGTH-(strlen(delim)+1), cmdf); remove_all(output, '\n'); + if(i == strlen(output)) + strcpy(output+i, last_update); + else + strcpy(last_update, output+i); + i = strlen(output); - if ((i > 0 && block != &blocks[LENGTH(blocks) - 1])) - strcat(output, delim); - i+=strlen(delim); + if ((i > 0 && block != &blocks[LENGTH(blocks) - 1])) + strcat(output, delim); + i+=strlen(delim); output[i++] = '\0'; pclose(cmdf); } @@ -92,7 +98,7 @@ void getcmds(int time) { current = blocks + i; if ((current->interval != 0 && time % current->interval == 0) || time == -1) - getcmd(current,statusbar[i]); + getcmd(current,last_updates[i],statusbar[i]); } } @@ -104,7 +110,7 @@ void getsigcmds(int signal) { current = blocks + i; if (current->signal == signal) - getcmd(current,statusbar[i]); + getcmd(current,last_updates[i],statusbar[i]); } } @@ -172,6 +178,11 @@ void statusloop() #ifndef __OpenBSD__ setupsignals(); #endif + last_updates = malloc(sizeof(char*) * LENGTH(blocks)); + for(int i = 0; i < LENGTH(blocks); i++) { + last_updates[i] = malloc(sizeof(char) * CMDLENGTH); + strcpy(last_updates[i],""); + } int i = 0; getcmds(-1); while(statusContinue) @@ -218,6 +229,10 @@ void buttonhandler(int sig, siginfo_t *si, void *ucontext) void termhandler(int signum) { + for(int i = 0; i < LENGTH(blocks); i++) { + free(last_updates[i]); + } + free(last_updates); statusContinue = 0; exit(0); } From 7e675aab544fa63256e295dbf997527e96afdfba Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 15 Feb 2021 21:26:39 -0500 Subject: [PATCH 10/13] sb-crypto removed --- config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/config.h b/config.h index eaf2dbe..ec4ff6e 100644 --- a/config.h +++ b/config.h @@ -7,7 +7,6 @@ static const Block blocks[] = { {"", "sb-music", 0, 11}, {"", "sb-pacpackages", 0, 8}, {"", "sb-news", 0, 6}, - /* {"", "sb-crypto", 0, 13}, */ /* {"", "sb-price lbc \"LBRY Token\" 📚", 9000, 22}, */ /* {"", "sb-price bat \"Basic Attention Token\" 🦁", 9000, 20}, */ /* {"", "sb-price link \"Chainlink\" 🔗", 300, 25}, */ From 9cd6f02395b5420d72e36ecadb612fc5b1537e56 Mon Sep 17 00:00:00 2001 From: Nihal Jere Date: Fri, 19 Feb 2021 15:04:06 -0600 Subject: [PATCH 11/13] ignore real-time signals by default, unless explicitly set --- dwmblocks.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dwmblocks.c b/dwmblocks.c index 68267d7..18f58fb 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -111,6 +111,10 @@ void getsigcmds(int signal) void setupsignals() { struct sigaction sa; + + for(int i = SIGRTMIN; i <= SIGRTMAX; i++) + signal(i, SIG_IGN); + for(int i = 0; i < LENGTH(blocks); i++) { if (blocks[i].signal > 0) From c9e45f9bed6fa44a7d0e29e4aee8ba93297d0cc0 Mon Sep 17 00:00:00 2001 From: Nihal Jere Date: Fri, 19 Feb 2021 15:10:38 -0600 Subject: [PATCH 12/13] update README.md --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 2b40431..7d21e30 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,7 @@ 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 if you signal an unexpected signal to dwmblocks, it will probably -crash. So if you disable a module, remember to also disable any cronjobs or -other scripts that might signal to that module. - -Note also that all modules must have different signal numbers. +Note that all modules must have different signal numbers. # Clickable modules From 826e3f1a990efb93f9bbf5d83512e63fc84007fe Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 2 Mar 2021 09:22:17 -0500 Subject: [PATCH 13/13] Revert "Mitigates disappearing blocks on fast mouse interaction" --- dwmblocks.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/dwmblocks.c b/dwmblocks.c index 5021af1..18f58fb 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -13,7 +13,6 @@ typedef struct { unsigned int interval; unsigned int signal; } Block; -char** last_updates; void sighandler(int num); void buttonhandler(int sig, siginfo_t *si, void *ucontext); void replace(char *str, char old, char new); @@ -62,7 +61,7 @@ void remove_all(char *str, char to_remove) { } //opens process *cmd and stores output in *output -void getcmd(const Block *block, char* last_update , char *output) +void getcmd(const Block *block, char *output) { if (block->signal) { @@ -78,15 +77,10 @@ void getcmd(const Block *block, char* last_update , char *output) int i = strlen(block->icon); fgets(output+i, CMDLENGTH-(strlen(delim)+1), cmdf); remove_all(output, '\n'); - if(i == strlen(output)) - strcpy(output+i, last_update); - else - strcpy(last_update, output+i); - i = strlen(output); - if ((i > 0 && block != &blocks[LENGTH(blocks) - 1])) - strcat(output, delim); - i+=strlen(delim); + if ((i > 0 && block != &blocks[LENGTH(blocks) - 1])) + strcat(output, delim); + i+=strlen(delim); output[i++] = '\0'; pclose(cmdf); } @@ -98,7 +92,7 @@ void getcmds(int time) { current = blocks + i; if ((current->interval != 0 && time % current->interval == 0) || time == -1) - getcmd(current,last_updates[i],statusbar[i]); + getcmd(current,statusbar[i]); } } @@ -110,7 +104,7 @@ void getsigcmds(int signal) { current = blocks + i; if (current->signal == signal) - getcmd(current,last_updates[i],statusbar[i]); + getcmd(current,statusbar[i]); } } @@ -182,11 +176,6 @@ void statusloop() #ifndef __OpenBSD__ setupsignals(); #endif - last_updates = malloc(sizeof(char*) * LENGTH(blocks)); - for(int i = 0; i < LENGTH(blocks); i++) { - last_updates[i] = malloc(sizeof(char) * CMDLENGTH); - strcpy(last_updates[i],""); - } int i = 0; getcmds(-1); while(statusContinue) @@ -233,10 +222,6 @@ void buttonhandler(int sig, siginfo_t *si, void *ucontext) void termhandler(int signum) { - for(int i = 0; i < LENGTH(blocks); i++) { - free(last_updates[i]); - } - free(last_updates); statusContinue = 0; exit(0); }