summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2021-04-14 10:42:52 +0200
committerbakkeby <[email protected]>2021-04-14 10:42:52 +0200
commit7efb64d68539666e8da8f7311e706954e6018fdb (patch)
tree983af71b683cd89ef62fd6e04f9bf1bb1d0707f2 /patch
parentbd5f5608a331b10746cde9c3ecbba24ae100f64d (diff)
downloaddwm-flexipatch-7efb64d68539666e8da8f7311e706954e6018fdb.tar.gz
dwm-flexipatch-7efb64d68539666e8da8f7311e706954e6018fdb.zip
Upgraded the dwmblocks patch for statuscmd which changes the signalling
mechanism from SIGUSR1 to SIGRTMIN which is likely to cause issues for those that already have a working setup. A compatibility option has been added which changes this back to SIGUSR1. Note that configuration was also changed. This was ref. reported issue #114.
Diffstat (limited to 'patch')
-rw-r--r--patch/bar_dwmblocks.c55
-rw-r--r--patch/bar_dwmblocks.h4
-rw-r--r--patch/bar_statuscmd.c10
3 files changed, 44 insertions, 25 deletions
diff --git a/patch/bar_dwmblocks.c b/patch/bar_dwmblocks.c
index 442b0bc..cb40d10 100644
--- a/patch/bar_dwmblocks.c
+++ b/patch/bar_dwmblocks.c
@@ -1,31 +1,50 @@
-static int dwmblockssig;
-pid_t dwmblockspid = 0;
+static int statussig;
+pid_t statuspid = -1;
-int
-getdwmblockspid()
+pid_t
+getstatusbarpid()
{
- char buf[16];
- FILE *fp = popen("pidof -s dwmblocks", "r");
- if (fgets(buf, sizeof(buf), fp));
- pid_t pid = strtoul(buf, NULL, 10);
+ 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);
- dwmblockspid = pid;
- return pid != 0 ? 0 : -1;
+ return strtol(buf, NULL, 10);
}
void
-sigdwmblocks(const Arg *arg)
+sigstatusbar(const Arg *arg)
{
union sigval sv;
- sv.sival_int = (dwmblockssig << 8) | arg->i;
- if (!dwmblockspid)
- if (getdwmblockspid() == -1)
- return;
- if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) {
+ 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 (!getdwmblockspid())
- sigqueue(dwmblockspid, SIGUSR1, sv);
+ if (!getstatusbarpid())
+ sigqueue(statuspid, SIGUSR1, sv);
}
}
+ #else
+ sv.sival_int = arg->i;
+ sigqueue(statuspid, SIGRTMIN+statussig, sv);
+ #endif // BAR_DWMBLOCKS_SIGUSR1_PATCH
} \ No newline at end of file
diff --git a/patch/bar_dwmblocks.h b/patch/bar_dwmblocks.h
index f08f1d5..07ac9b3 100644
--- a/patch/bar_dwmblocks.h
+++ b/patch/bar_dwmblocks.h
@@ -1,2 +1,2 @@
-static int getdwmblockspid();
-static void sigdwmblocks(const Arg *arg); \ No newline at end of file
+static int getstatusbarpid();
+static void sigstatusbar(const Arg *arg); \ No newline at end of file
diff --git a/patch/bar_statuscmd.c b/patch/bar_statuscmd.c
index 0a4ad72..ae1e2bb 100644
--- a/patch/bar_statuscmd.c
+++ b/patch/bar_statuscmd.c
@@ -25,7 +25,7 @@ click_statuscmd_text(Arg *arg, int rel_x, char *text)
int x = 0;
char ch;
#if BAR_DWMBLOCKS_PATCH
- dwmblockssig = -1;
+ statussig = -1;
#else
statuscmdn = 0;
#endif // BAR_DWMBLOCKS_PATCH
@@ -42,9 +42,9 @@ click_statuscmd_text(Arg *arg, int rel_x, char *text)
text += i+1;
i = -1;
#if BAR_DWMBLOCKS_PATCH
- if (x >= rel_x && dwmblockssig != -1)
+ if (x >= rel_x && statussig != -1)
break;
- dwmblockssig = ch;
+ statussig = ch;
#else
if (x >= rel_x)
break;
@@ -54,8 +54,8 @@ click_statuscmd_text(Arg *arg, int rel_x, char *text)
}
}
#if BAR_DWMBLOCKS_PATCH
- if (dwmblockssig == -1)
- dwmblockssig = 0;
+ if (statussig == -1)
+ statussig = 0;
#endif // BAR_DWMBLOCKS_PATCH
return ClkStatusText;
}