diff options
author | Daniel Bylinka <daniel.bylinka@gmail.com> | 2020-05-18 00:52:18 +0200 |
---|---|---|
committer | Daniel Bylinka <daniel.bylinka@gmail.com> | 2020-05-18 00:52:18 +0200 |
commit | aaeebc4b367f4482ddc983e30a8d97e87b6c701a (patch) | |
tree | fc64956a679803a31e2de9aab5f0fe04c295f142 /dwmblocks.c | |
parent | ff026b9dd4d05eac027af0debb06637483d68b3b (diff) | |
download | dwmblocks-aaeebc4b367f4482ddc983e30a8d97e87b6c701a.tar.gz dwmblocks-aaeebc4b367f4482ddc983e30a8d97e87b6c701a.tar.bz2 dwmblocks-aaeebc4b367f4482ddc983e30a8d97e87b6c701a.zip |
Update status after forking and export with setenv
Forking after updating the status can feel unresponsive depending on how
long it takes for the command to run.
Also link to the statuscmd page on suckless.org instead of the gist.
Diffstat (limited to 'dwmblocks.c')
-rw-r--r-- | dwmblocks.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/dwmblocks.c b/dwmblocks.c index 64c2da2..bf648c2 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -184,29 +184,25 @@ void sighandler(int signum) void buttonhandler(int sig, siginfo_t *si, void *ucontext) { - int button = si->si_value.sival_int & 0xff; + char button[2] = {'0' + si->si_value.sival_int & 0xff, '\0'}; 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++) + for (int 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 }; + char *command[] = { "/bin/sh", "-c", current->command, NULL }; + setenv("BLOCK_BUTTON", button, 1); setsid(); execvp(command[0], command); exit(EXIT_SUCCESS); - cmd[22] = '\0'; } + getsigcmds(sig); + writestatus(); } #endif |