diff --git a/README.md b/README.md index 468b9e4..573ff08 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2020-05-02 - Added dwmblocks patch + 2020-04-27 - Upgraded the tagmonfixfs patch to better support moving fullscreen windows to adjacent monitors 2020-04-26 - Expanded monitor rules patch to include nmaster, showbar and topbar options @@ -169,6 +171,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - lets you resize the split in layouts (i.e. modify mfact) by holding the modkey + shift + left-click and dragging the mouse - this is a bespoke patch that supports vertical and horizontal layout splits as well as centered master variants + - [dwmblocks](https://gist.github.com/danbyl/54f7c1d57fc6507242a95b71c3d8fdea) + - signal integration to use dwm with a patched [dwmblocks](https://github.com/torrinfail/dwmblocks) + - combined with the statuscmd patch this gives a clickable statusbar + - [dwmc](http://dwm.suckless.org/patches/dwmc/) - a simple dwmc client using a fork of fsignal to communicate with dwm diff --git a/config.def.h b/config.def.h index 50bcff6..c052c15 100644 --- a/config.def.h +++ b/config.def.h @@ -977,7 +977,11 @@ static Button buttons[] = { { ClkWinTitle, 0, Button3, showhideclient, {0} }, #endif // AWESOMEBAR_PATCH { ClkWinTitle, 0, Button2, zoom, {0} }, - #if STATUSCMD_PATCH + #if STATUSCMD_PATCH && DWMBLOCKS_PATCH + { ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1 } }, + { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2 } }, + { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3 } }, + #elif STATUSCMD_PATCH { ClkStatusText, 0, Button1, spawn, {.v = statuscmd } }, { ClkStatusText, 0, Button2, spawn, {.v = statuscmd } }, { ClkStatusText, 0, Button3, spawn, {.v = statuscmd } }, diff --git a/dwm.c b/dwm.c index c3c5f4f..8940102 100644 --- a/dwm.c +++ b/dwm.c @@ -797,7 +797,11 @@ buttonpress(XEvent *e) char *text = rawstext; int i = -1; char ch; + #if DWMBLOCKS_PATCH + dwmblockssig = 0; + #else statuscmdn = 0; + #endif // DWMBLOCKS_PATCH while (text[++i]) { if ((unsigned char)text[i] < ' ') { ch = text[i]; @@ -808,8 +812,12 @@ buttonpress(XEvent *e) i = -1; if (xc >= ev->x) break; + #if DWMBLOCKS_PATCH + dwmblockssig = ch; + #else if (ch <= LENGTH(statuscmds)) statuscmdn = ch - 1; + #endif // DWMBLOCKS_PATCH } } } @@ -886,7 +894,11 @@ buttonpress(XEvent *e) char *text = rawstext; int i = -1; char ch; + #if DWMBLOCKS_PATCH + dwmblockssig = 0; + #else statuscmdn = 0; + #endif // DWMBLOCKS_PATCH while (text[++i]) { if ((unsigned char)text[i] < ' ') { ch = text[i]; @@ -897,8 +909,12 @@ buttonpress(XEvent *e) i = -1; if (xc >= ev->x) break; + #if DWMBLOCKS_PATCH + dwmblockssig = ch; + #else if (ch <= LENGTH(statuscmds)) statuscmdn = ch - 1; + #endif // DWMBLOCKS_PATCH } } } diff --git a/patch/dwmblocks.c b/patch/dwmblocks.c new file mode 100644 index 0000000..442b0bc --- /dev/null +++ b/patch/dwmblocks.c @@ -0,0 +1,31 @@ +static int dwmblockssig; +pid_t dwmblockspid = 0; + +int +getdwmblockspid() +{ + char buf[16]; + FILE *fp = popen("pidof -s dwmblocks", "r"); + if (fgets(buf, sizeof(buf), fp)); + pid_t pid = strtoul(buf, NULL, 10); + pclose(fp); + dwmblockspid = pid; + return pid != 0 ? 0 : -1; +} + +void +sigdwmblocks(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 (errno == ESRCH) { + if (!getdwmblockspid()) + sigqueue(dwmblockspid, SIGUSR1, sv); + } + } +} \ No newline at end of file diff --git a/patch/dwmblocks.h b/patch/dwmblocks.h new file mode 100644 index 0000000..f08f1d5 --- /dev/null +++ b/patch/dwmblocks.h @@ -0,0 +1,2 @@ +static int getdwmblockspid(); +static void sigdwmblocks(const Arg *arg); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 42b35f4..f3f71e4 100644 --- a/patch/include.c +++ b/patch/include.c @@ -29,6 +29,9 @@ #if DRAGCFACT_PATCH && CFACTS_PATCH #include "dragcfact.c" #endif +#if DWMBLOCKS_PATCH && STATUSCMD_PATCH +#include "dwmblocks.c" +#endif #if DWMC_PATCH #include "dwmc.c" #elif FSIGNAL_PATCH diff --git a/patch/include.h b/patch/include.h index 51b51da..2dad7f1 100644 --- a/patch/include.h +++ b/patch/include.h @@ -32,6 +32,9 @@ #if DRAGMFACT_PATCH #include "dragmfact.h" #endif +#if DWMBLOCKS_PATCH && STATUSCMD_PATCH +#include "dwmblocks.h" +#endif #if DWMC_PATCH #include "dwmc.h" #elif FSIGNAL_PATCH diff --git a/patches.def.h b/patches.def.h index 72fabc3..3549885 100644 --- a/patches.def.h +++ b/patches.def.h @@ -140,6 +140,13 @@ */ #define DRAGMFACT_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 + * dwmblocks: https://github.com/torrinfail/dwmblocks + */ +#define DWMBLOCKS_PATCH 0 + /* Simple dwmc client using a fork of fsignal to communicate with dwm. * To use this either copy the patch/dwmc shell script to somewhere in your path or * uncomment the following line in Makefile: