diff options
| author | Bear <bear@bengtsson.win> | 2021-12-27 09:29:58 +0000 |
|---|---|---|
| committer | Bear <bear@bengtsson.win> | 2021-12-27 09:29:58 +0000 |
| commit | 69262b01ced79c2d776fab9b889926d1816a1e7a (patch) | |
| tree | f304cd6fa8734e83a7772d07dc9b484781565155 /patch/bar_dwmblocks.c | |
Added DWM
Diffstat (limited to 'patch/bar_dwmblocks.c')
| -rw-r--r-- | patch/bar_dwmblocks.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/patch/bar_dwmblocks.c b/patch/bar_dwmblocks.c new file mode 100644 index 0000000..25268c5 --- /dev/null +++ b/patch/bar_dwmblocks.c @@ -0,0 +1,51 @@ +static int statussig; +pid_t statuspid = -1; + +pid_t +getstatusbarpid() +{ + char buf[32], *str = buf, *c; + FILE *fp; + + if (statuspid > 0) { + snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid); + if ((fp = fopen(buf, "r"))) { + fgets(buf, sizeof(buf), fp); + while ((c = strchr(str, '/'))) + str = c + 1; + fclose(fp); + if (!strcmp(str, STATUSBAR)) + return statuspid; + } + } + if (!(fp = popen("pidof -s "STATUSBAR, "r"))) + return -1; + fgets(buf, sizeof(buf), fp); + pclose(fp); + return strtol(buf, NULL, 10); +} + +void +sigstatusbar(const Arg *arg) +{ + union sigval sv; + + if (!statussig) + return; + if ((statuspid = getstatusbarpid()) <= 0) + return; + + #if BAR_DWMBLOCKS_SIGUSR1_PATCH + sv.sival_int = (statussig << 8) | arg->i; + if (sigqueue(statuspid, SIGUSR1, sv) == -1) { + if (errno == ESRCH) { + if (!getstatusbarpid()) + sigqueue(statuspid, SIGUSR1, sv); + } + } + #else + sv.sival_int = arg->i; + sigqueue(statuspid, SIGRTMIN+statussig, sv); + #endif // BAR_DWMBLOCKS_SIGUSR1_PATCH +} + |
