From: torrinfail Date: Wed, 12 Aug 2020 03:04:51 +0000 (-0700) Subject: Merge pull request #15 from tomboehmer/issue9 X-Git-Url: https://git.armaanb.net/?p=dwmblocks.git;a=commitdiff_plain;h=d2e6d20ebf269f1074e7afc206d4c3d3b556fc9f;hp=-c Merge pull request #15 from tomboehmer/issue9 Fixes #9 - determine the size of the status buffer based on the number of blocks --- d2e6d20ebf269f1074e7afc206d4c3d3b556fc9f diff --combined dwmblocks.c index 8668f04,3af799f..21c1482 --- a/dwmblocks.c +++ b/dwmblocks.c @@@ -6,6 -6,7 +6,7 @@@ #include #define LENGTH(X) (sizeof(X) / sizeof (X[0])) #define CMDLENGTH 50 + #define STATUSLENGTH (LENGTH(blocks) * CMDLENGTH + 1) typedef struct { char* icon; @@@ -13,7 -14,6 +14,7 @@@ unsigned int interval; unsigned int signal; } Block; +void dummysighandler(int num); void sighandler(int num); void getcmds(int time); #ifndef __OpenBSD__ @@@ -33,7 -33,7 +34,7 @@@ static Display *dpy static int screen; static Window root; static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; - static char statusstr[2][256]; + static char statusstr[2][STATUSLENGTH]; static int statusContinue = 1; static void (*writestatus) () = setroot; @@@ -59,7 -59,7 +60,7 @@@ void getcmds(int time { const Block* current; for(int i = 0; i < LENGTH(blocks); i++) - { + { current = blocks + i; if ((current->interval != 0 && time % current->interval == 0) || time == -1) getcmd(current,statusbar[i]); @@@ -80,12 -80,8 +81,12 @@@ void getsigcmds(int signal void setupsignals() { + /* initialize all real time signals with dummy handler */ + for(int i = SIGRTMIN; i <= SIGRTMAX; i++) + signal(i, dummysighandler); + for(int i = 0; i < LENGTH(blocks); i++) - { + { if (blocks[i].signal > 0) signal(SIGRTMIN+blocks[i].signal, sighandler); } @@@ -142,14 -138,6 +143,14 @@@ void statusloop( } } +#ifndef __OpenBSD__ +/* this signal handler should do nothing */ +void dummysighandler(int signum) +{ + return; +} +#endif + #ifndef __OpenBSD__ void sighandler(int signum) { @@@ -167,7 -155,7 +168,7 @@@ void termhandler(int signum int main(int argc, char** argv) { for(int i = 0; i < argc; i++) - { + { if (!strcmp("-d",argv[i])) delim = argv[++i][0]; else if(!strcmp("-p",argv[i]))