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.
This commit is contained in:
bakkeby 2021-04-14 10:42:52 +02:00
parent bd5f5608a3
commit 7efb64d685
6 changed files with 85 additions and 34 deletions

View File

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2021-04-14 - 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.
2021-04-07 - Added xkb patch
2021-04-06 - Added the distributetags patch

View File

@ -774,11 +774,16 @@ static const char *dmenucmd[] = {
};
static const char *termcmd[] = { "st", NULL };
#if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH
#if BAR_STATUSCMD_PATCH
#if BAR_DWMBLOCKS_PATCH
/* This defines the name of the executable that handles the bar (used for signalling purposes) */
#define STATUSBAR "dwmblocks"
#else
/* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */
static const char *statuscmds[] = { "notify-send Mouse$BUTTON" };
static const char *statuscmds[] = { "notify-send Mouse$BUTTON", "notify-send Cat$BUTTON", "notify-send Dog$BUTTON" };
static char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL };
#endif // BAR_STATUSCMD_PATCH | DWMBLOCKS_PATCH
#endif // BAR_DWMBLOCKS_PATCH
#endif // BAR_STATUSCMD_PATCH
#if ON_EMPTY_KEYS_PATCH
static const char* firefoxcmd[] = {"firefox", NULL};
@ -1209,9 +1214,9 @@ static Button buttons[] = {
#endif // BAR_WINTITLEACTIONS_PATCH
{ ClkWinTitle, 0, Button2, zoom, {0} },
#if BAR_STATUSCMD_PATCH && BAR_DWMBLOCKS_PATCH
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1 } },
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2 } },
{ ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3 } },
{ ClkStatusText, 0, Button1, sigstatusbar, {.i = 1 } },
{ ClkStatusText, 0, Button2, sigstatusbar, {.i = 2 } },
{ ClkStatusText, 0, Button3, sigstatusbar, {.i = 3 } },
#elif BAR_STATUSCMD_PATCH
{ ClkStatusText, 0, Button1, spawn, {.v = statuscmd } },
{ ClkStatusText, 0, Button2, spawn, {.v = statuscmd } },

View File

@ -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
}

View File

@ -1,2 +1,2 @@
static int getdwmblockspid();
static void sigdwmblocks(const Arg *arg);
static int getstatusbarpid();
static void sigstatusbar(const Arg *arg);

View File

@ -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;
}

View File

@ -21,13 +21,38 @@
*/
#define BAR_AWESOMEBAR_PATCH 0
/* This patch depends on statuscmd patch and adds integration with a (patched) dwmblocks
* instance to give a clickable status bar.
* Patch: https://gist.github.com/danbyl/54f7c1d57fc6507242a95b71c3d8fdea
/* This patch depends on statuscmd patch and adds integration with a (patched)
* dwmblocks instance to give a clickable status bar. One must not necessarily
* have to use dwmblocks for this feature, any status updater that has support
* for real-time signals (SIGRTMIN) can be used.
*
* dwmblocks: https://github.com/torrinfail/dwmblocks
* https://dwm.suckless.org/patches/statuscmd/
*/
#define BAR_DWMBLOCKS_PATCH 0
/* Originally the dwmblocks + statuscmd patch used a user defined signal (SIGUSR1)
* for communicating with dwmblocks to indicate update signal and what button was
* pressed. The signalling was later changed to SIGRTMIN instead.
*
* Ultimately this makes dwmblocks instances that were patched with the old patch
* are incompatible with the new dwm patch and vice versa.
*
* This is a compatibility patch that makes dwm use SIGUSR1 instead of SIGRTMIN so
* if button clicks are not working then you may want to try enabling this.
*
* If dwmblocks happen to die like this when clicking on a status
*
* [1] 54355 user-defined signal 1 dwmblocks
*
* then it suggests that dwmblocks does not support user defined signals and this
* patch should be left disabled.
*
* Patch: https://gist.github.com/danbyl/54f7c1d57fc6507242a95b71c3d8fdea
* https://dwm.suckless.org/patches/statuscmd/
*/
#define BAR_DWMBLOCKS_SIGUSR1_PATCH 0
/* This patch shows the titles of all visible windows in the status bar
* (as opposed to showing only the selected one).
* Awesomebar takes precedence over fancybar. Fancybar takes precedence over