summaryrefslogtreecommitdiff
path: root/dwmblocks.c
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2020-05-26 07:26:42 -0400
committerGitHub <noreply@github.com>2020-05-26 07:26:42 -0400
commit6d75ac1b00482e842f3e600cddde3b31a1c35ede (patch)
tree14e17d12341cec0d909212d1dbdac07f5a955325 /dwmblocks.c
parent0666c8a14d4c87ec7fda7d9fa146f6a292126b3b (diff)
parent373d96844fb93e4a2e5aee4d3b9f866c032190a4 (diff)
downloaddwmblocks-6d75ac1b00482e842f3e600cddde3b31a1c35ede.tar.gz
dwmblocks-6d75ac1b00482e842f3e600cddde3b31a1c35ede.tar.bz2
dwmblocks-6d75ac1b00482e842f3e600cddde3b31a1c35ede.zip
Merge pull request #23 from danbyl/forkbefore
Update status after forking and export with setenv
Diffstat (limited to 'dwmblocks.c')
-rw-r--r--dwmblocks.c16
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
Software created with 💖