diff --git a/Makefile b/Makefile index c2c3c6b..5cfbb5a 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,15 @@ .POSIX: PREFIX = /usr/local +CC = gcc -output: dwmblocks.o - gcc dwmblocks.o -lX11 -o dwmblocks +dwmblocks: dwmblocks.o + $(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: output +install: dwmblocks mkdir -p $(DESTDIR)$(PREFIX)/bin cp -f dwmblocks $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/dwmblocks diff --git a/README.md b/README.md index b6a4685..7d21e30 100644 --- a/README.md +++ b/README.md @@ -31,9 +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 that all modules must have different signal numbers. # Clickable modules diff --git a/config.h b/config.h index ce85fe0..8bd92b9 100644 --- a/config.h +++ b/config.h @@ -14,7 +14,3 @@ static const Block blocks[] = { {"", "battery", 5, 3}, {"", "clock", 1, 1}, }; - -//sets delimeter between status commands. NULL character ('\0') means no delimeter. -static char *delim = "|"; - diff --git a/dwmblocks.c b/dwmblocks.c index 1d31a65..26ca6b0 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -114,6 +114,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) @@ -210,6 +214,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) { @@ -220,14 +225,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