summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2019-10-07 23:34:23 +0200
committerbakkeby <[email protected]>2019-10-07 23:34:23 +0200
commitca8638128f96f3309451577b600dc2840511ef97 (patch)
tree605e574ee83a76575032c44972426b63216c5ed8
parent2612060419c9c19a743f63393154abe176177f3c (diff)
downloaddwm-flexipatch-ca8638128f96f3309451577b600dc2840511ef97.tar.gz
dwm-flexipatch-ca8638128f96f3309451577b600dc2840511ef97.zip
Adding dwmc patch
-rw-r--r--Makefile1
-rw-r--r--README.md5
-rw-r--r--dwm.c9
-rwxr-xr-xpatch/dwmc40
-rw-r--r--patch/dwmc.c113
-rw-r--r--patch/dwmc.h13
-rw-r--r--patch/include.c4
-rw-r--r--patch/include.h4
-rw-r--r--patches.h7
9 files changed, 192 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 77bcbc0..d1e402b 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,7 @@ dist: clean
install: all
mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f dwm ${DESTDIR}${PREFIX}/bin
+ #cp -f patch/dwmc ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
mkdir -p ${DESTDIR}${MANPREFIX}/man1
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
diff --git a/README.md b/README.md
index e88a305..8326aaf 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
-2019-10-07 - Added sortscreens patch
+2019-10-07 - Added sortscreens and dwmc patches
2019-10-06 - Added statuscolors and statusallmons patches, fixed minor cross-compatibility issues for killunsel, fullscreen, noborder, tagintostack patches
@@ -101,6 +101,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/)
- lets you cycle through all your layouts
+ - [dwmc](http://dwm.suckless.org/patches/dwmc/)
+ - a simple dwmc client using a fork of fsignal to communicate with dwm
+
- [emptyview](https://dwm.suckless.org/patches/emptyview/)
- allows no tag at all to be selected
- dwm will start with no tag selected and when a client with no tag rule is started and no tag is selected then it will be opened on the first tag
diff --git a/dwm.c b/dwm.c
index ce47e2f..27d3ec5 100644
--- a/dwm.c
+++ b/dwm.c
@@ -2069,11 +2069,14 @@ propertynotify(XEvent *e)
}
#endif // SYSTRAY_PATCH
- if ((ev->window == root) && (ev->atom == XA_WM_NAME))
+ if ((ev->window == root) && (ev->atom == XA_WM_NAME)) {
+ #if DWMC_PATCH
+ if (!fake_signal())
+ #endif // DWMC_PATCH
updatestatus();
- else if (ev->state == PropertyDelete)
+ } else if (ev->state == PropertyDelete) {
return; /* ignore */
- else if ((c = wintoclient(ev->window))) {
+ } else if ((c = wintoclient(ev->window))) {
switch(ev->atom) {
default: break;
case XA_WM_TRANSIENT_FOR:
diff --git a/patch/dwmc b/patch/dwmc
new file mode 100755
index 0000000..9e3ecd6
--- /dev/null
+++ b/patch/dwmc
@@ -0,0 +1,40 @@
+#!/usr/bin/env sh
+
+signal() {
+ xsetroot -name "fsignal:$*"
+}
+
+case $# in
+1)
+ case $1 in
+ setlayout | view | viewall | togglebar | togglefloating | zoom | killclient | quit)
+ signal $1
+ ;;
+ *)
+ echo "Unknown command or missing one argument."
+ exit 1
+ ;;
+ esac
+ ;;
+2)
+ case $1 in
+ view)
+ signal $1 ui $2
+ ;;
+ viewex | toggleviewex | tagex | toggletagex | setlayoutex | focusstack | incnmaster | focusmon | tagmon)
+ signal $1 i $2
+ ;;
+ setmfact)
+ signal $1 f $2
+ ;;
+ *)
+ echo "Unknown command or one too many arguments."
+ exit 1
+ ;;
+ esac
+ ;;
+*)
+ echo "Too many arguments."
+ exit 1
+ ;;
+esac \ No newline at end of file
diff --git a/patch/dwmc.c b/patch/dwmc.c
new file mode 100644
index 0000000..bd71d80
--- /dev/null
+++ b/patch/dwmc.c
@@ -0,0 +1,113 @@
+void
+setlayoutex(const Arg *arg)
+{
+ setlayout(&((Arg) { .v = &layouts[arg->i] }));
+}
+
+void
+viewex(const Arg *arg)
+{
+ view(&((Arg) { .ui = 1 << arg->ui }));
+}
+
+void
+viewallex(const Arg *arg)
+{
+ view(&((Arg){.ui = ~0}));
+}
+
+void
+toggleviewex(const Arg *arg)
+{
+ toggleview(&((Arg) { .ui = 1 << arg->ui }));
+}
+
+void
+tagex(const Arg *arg)
+{
+ tag(&((Arg) { .ui = 1 << arg->ui }));
+}
+
+void
+toggletagex(const Arg *arg)
+{
+ toggletag(&((Arg) { .ui = 1 << arg->ui }));
+}
+
+void
+tagallex(const Arg *arg)
+{
+ tag(&((Arg){.ui = ~0}));
+}
+
+/* signal definitions */
+/* signum must be greater than 0 */
+/* trigger signals using `xsetroot -name "fsignal:<signame> [<type> <value>]"` */
+static Signal signals[] = {
+ /* signum function */
+ { "focusstack", focusstack },
+ { "setmfact", setmfact },
+ { "togglebar", togglebar },
+ { "incnmaster", incnmaster },
+ { "togglefloating", togglefloating },
+ { "focusmon", focusmon },
+ { "tagmon", tagmon },
+ { "zoom", zoom },
+ { "view", view },
+ { "viewall", viewallex },
+ { "viewex", viewex },
+ { "toggleview", view },
+ { "toggleviewex", toggleviewex },
+ { "tag", tag },
+ { "tagall", tagallex },
+ { "tagex", tagex },
+ { "toggletag", tag },
+ { "toggletagex", toggletagex },
+ { "killclient", killclient },
+ { "quit", quit },
+ { "setlayout", setlayout },
+ { "setlayoutex", setlayoutex },
+};
+
+int
+fake_signal(void)
+{
+ char fsignal[256];
+ char indicator[9] = "fsignal:";
+ char str_sig[50];
+ char param[16];
+ int i, len_str_sig, n, paramn;
+ size_t len_fsignal, len_indicator = strlen(indicator);
+ Arg arg;
+
+ // Get root name property
+ if (gettextprop(root, XA_WM_NAME, fsignal, sizeof(fsignal))) {
+ len_fsignal = strlen(fsignal);
+
+ // Check if this is indeed a fake signal
+ if (len_indicator > len_fsignal ? 0 : strncmp(indicator, fsignal, len_indicator) == 0) {
+ paramn = sscanf(fsignal+len_indicator, "%s%n%s%n", str_sig, &len_str_sig, param, &n);
+
+ if (paramn == 1) arg = (Arg) {0};
+ else if (paramn > 2) return 1;
+ else if (strncmp(param, "i", n - len_str_sig) == 0)
+ sscanf(fsignal + len_indicator + n, "%i", &(arg.i));
+ else if (strncmp(param, "ui", n - len_str_sig) == 0)
+ sscanf(fsignal + len_indicator + n, "%u", &(arg.ui));
+ else if (strncmp(param, "f", n - len_str_sig) == 0)
+ sscanf(fsignal + len_indicator + n, "%f", &(arg.f));
+ else return 1;
+
+ // Check if a signal was found, and if so handle it
+ for (i = 0; i < LENGTH(signals); i++)
+ if (strncmp(str_sig, signals[i].sig, len_str_sig) == 0 && signals[i].func)
+ signals[i].func(&(arg));
+
+ // A fake signal was sent
+ return 1;
+ }
+ }
+
+ // No fake signal was sent, so proceed with update
+ return 0;
+} \ No newline at end of file
diff --git a/patch/dwmc.h b/patch/dwmc.h
new file mode 100644
index 0000000..1711081
--- /dev/null
+++ b/patch/dwmc.h
@@ -0,0 +1,13 @@
+typedef struct {
+ const char * sig;
+ void (*func)(const Arg *);
+} Signal;
+
+static void setlayoutex(const Arg *arg);
+static void viewex(const Arg *arg);
+static void viewallex(const Arg *arg);
+static void toggleviewex(const Arg *arg);
+static void tagex(const Arg *arg);
+static void toggletagex(const Arg *arg);
+static void tagallex(const Arg *arg);
+static int fake_signal(void); \ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index 1bc7fcb..27eb415 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -36,6 +36,10 @@
#include "cyclelayouts.c"
#endif
+#if DWMC_PATCH
+#include "dwmc.c"
+#endif
+
#if EWMHTAGS_PATCH
#include "ewmhtags.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index 35c6423..9d77d76 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -36,6 +36,10 @@
#include "cyclelayouts.h"
#endif
+#if DWMC_PATCH
+#include "dwmc.h"
+#endif
+
#if EWMHTAGS_PATCH
#include "ewmhtags.h"
#endif
diff --git a/patches.h b/patches.h
index 1b18ad0..cf523a0 100644
--- a/patches.h
+++ b/patches.h
@@ -115,6 +115,13 @@
*/
#define CYCLELAYOUTS_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: #cp -f patch/dwmc ${DESTDIR}${PREFIX}/bin
+ * http://dwm.suckless.org/patches/dwmc/
+ */
+#define DWMC_PATCH 0
+
/* This patch allows no tag at all to be selected. The result is that dwm will start with
* no tag selected and when you start a client with no tag rule and no tag selected then
* it will be opened on the first tag.