dwmblocks.diff (2140B)
1 6c6 2 < #include<syswait.h> 3 --- 4 > #include<sys/wait.h> 5 18c18 6 < #define CMDLENGTH 50 7 --- 8 > #define CMDLENGTH 120 // default was 50 9 31d30 10 < void sighandler(int num); 11 35c34 12 < void sighandler(int signum); 13 --- 14 > void sighandler(int signum, siginfo_t *si, void *ucontext); 15 38a38 16 > void chldhandler(); 17 63,64c63,64 18 < if (block->signal) 19 < *output++ = block->signal; 20 --- 21 > if (block->signal) 22 > *output++ = block->signal; 23 77,78d76 24 < //only chop off newline if one is present at the end 25 < i = output[i-1] == '\n' ? i-1 : i; 26 79a78,79 27 > //only chop off newline if one is present at the end 28 > i = output[i-1] == '\n' ? i-1 : i; 29 109c109 30 < struct sigaction sa = { .sa_sigaction = sighandler, .sa_flags = SA_SIGINFO }; 31 --- 32 > struct sigaction sa = { .sa_sigaction = sighandler, .sa_flags = SA_SIGINFO }; 33 112c112 34 < for (int i = SIGRTMIN; i <= SIGRTMAX; i++){ 35 --- 36 > for (int i = SIGRTMIN; i <= SIGRTMAX; i++) { 37 114,115c114,115 38 < sigaddset(&sa.sa_mask, i); 39 < } 40 --- 41 > sigaddset(&sa.sa_mask, i); 42 > } 43 120c120 44 < signal(SIGMINUS+blocks[i].signal, sighandler); 45 --- 46 > sigaction(SIGMINUS+blocks[i].signal, &sa, NULL); 47 188c188 48 < void sighandler(int signum) 49 --- 50 > void sighandler(int signum, siginfo_t *si, void *ucontext) 51 190,191c190,213 52 < getsigcmds(signum-SIGPLUS); 53 < writestatus(); 54 --- 55 > if (si->si_value.sival_int) { 56 > pid_t parent = getpid(); 57 > if (fork() == 0) { 58 > #ifndef NO_X 59 > if (dpy) 60 > close(ConnectionNumber(dpy)); 61 > #endif 62 > int i; 63 > for (i = 0; i < LENGTH(blocks) && blocks[i].signal != signum-SIGRTMIN; i++); 64 > 65 > char shcmd[1024]; 66 > sprintf(shcmd, "%s; kill -%d %d", blocks[i].command, SIGRTMIN+blocks[i].signal, parent); 67 > char *cmd[] = { "/bin/sh", "-c", shcmd, NULL }; 68 > char button[2] = { '0' + si->si_value.sival_int, '\0' }; 69 > setenv("BLOCK_BUTTON", button, 1); 70 > setsid(); 71 > execvp(cmd[0], cmd); 72 > perror(cmd[0]); 73 > exit(EXIT_SUCCESS); 74 > } 75 > } else { 76 > getsigcmds(signum-SIGPLUS); 77 > writestatus(); 78 > } 79 198a221,225 80 > void chldhandler() 81 > { 82 > while (0 < waitpid(-1, NULL, WNOHANG)); 83 > } 84 > 85 214a242 86 > signal(SIGCHLD, chldhandler);