commit 8c80b3e57649e1f9458d94463210146a37ef1193
Author: Daniel Perez Alvarez <danielpza_AT_protonmail.com>
Date: Sun Sep 29 16:56:58 2019 +0000
[dwm][patch][dwmc] add dwmc forked from fsignal
diff --git a/dwm.suckless.org/patches/dwmc/dwm-dwmc-6.2.diff b/dwm.suckless.org/patches/dwmc/dwm-dwmc-6.2.diff
new file mode 100644
index 00000000..73b2b01c
--- /dev/null
+++ b/dwm.suckless.org/patches/dwmc/dwm-dwmc-6.2.diff
_AT_@ -0,0 +1,237 @@
+From f2af4bc3699461833d614dbd1610123b1c315853 Mon Sep 17 00:00:00 2001
+From: Daniel Perez Alvarez <danielpza_AT_protonmail.com>
+Date: Sat, 28 Sep 2019 15:17:28 +0000
+Subject: [PATCH] dwm-client
+
+---
+ Makefile | 2 +-
+ config.def.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
+ dwm.c | 52 +++++++++++++++++++++++++++++++++++++-
+ dwmc | 40 ++++++++++++++++++++++++++++++
+ 4 files changed, 162 insertions(+), 2 deletions(-)
+ create mode 100755 dwmc
+
+diff --git a/Makefile b/Makefile
+index 77bcbc0..f837f5c 100644
+--- a/Makefile
++++ b/Makefile
+_AT_@ -38,7 +38,7 @@ dist: clean
+
+ install: all
+ mkdir -p ${DESTDIR}${PREFIX}/bin
+- cp -f dwm ${DESTDIR}${PREFIX}/bin
++ cp -f dwm 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/config.def.h b/config.def.h
+index 1c0b587..efbae79 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -113,3 +113,73 @@ static Button buttons[] = {
+ { ClkTagBar, MODKEY, Button3, toggletag, {0} },
+ };
+
++void
++setlayoutex(const Arg *arg)
++{
++ setlayout(&((Arg) { .v = &layouts[arg->i] }));
++}
++
++void
++viewex(const Arg *arg)
++{
++ view(&((Arg) { .ui = 1 << arg->ui }));
++}
++
++void
++viewall(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
++tagall(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", viewall },
++ { "viewex", viewex },
++ { "toggleview", view },
++ { "toggleviewex", toggleviewex },
++ { "tag", tag },
++ { "tagall", tagall },
++ { "tagex", tagex },
++ { "toggletag", tag },
++ { "toggletagex", toggletagex },
++ { "killclient", killclient },
++ { "quit", quit },
++ { "setlayout", setlayout },
++ { "setlayoutex", setlayoutex },
++};
+diff --git a/dwm.c b/dwm.c
+index 4465af1..e0fc838 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -106,6 +106,11 @@ typedef struct {
+ const Arg arg;
+ } Key;
+
++typedef struct {
++ const char * sig;
++ void (*func)(const Arg *);
++} Signal;
++
+ typedef struct {
+ const char *symbol;
+ void (*arrange)(Monitor *);
+_AT_@ -148,6 +153,7 @@ static void arrange(Monitor *m);
+ static void arrangemon(Monitor *m);
+ static void attach(Client *c);
+ static void attachstack(Client *c);
++static int fake_signal(void);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+ static void cleanup(void);
+_AT_@ -998,6 +1004,49 @@ keypress(XEvent *e)
+ keys[i].func(&(keys[i].arg));
+ }
+
++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;
++}
++
+ void
+ killclient(const Arg *arg)
+ {
+_AT_@ -1216,7 +1265,8 @@ propertynotify(XEvent *e)
+ XPropertyEvent *ev = &e->xproperty;
+
+ if ((ev->window == root) && (ev->atom == XA_WM_NAME))
+- updatestatus();
++ if (!fake_signal())
++ updatestatus();
+ else if (ev->state == PropertyDelete)
+ return; /* ignore */
+ else if ((c = wintoclient(ev->window))) {
+diff --git a/dwmc b/dwmc
+new file mode 100755
+index 0000000..5ff8dbc
+--- /dev/null
++++ b/dwmc
+_AT_@ -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
+--
+2.17.1
+
diff --git a/dwm.suckless.org/patches/dwmc/index.md b/dwm.suckless.org/patches/dwmc/index.md
new file mode 100644
index 00000000..0b9250ae
--- /dev/null
+++ b/dwm.suckless.org/patches/dwmc/index.md
_AT_@ -0,0 +1,25 @@
+dwmc
+====
+
+Description
+-----------
+Simple dwmc client using a fork of
+[fsignal](../fsignal/) to communicate with dwm.
+
+Example
+-------
+
+See
+[here](
https://github.com/danielpza/dotfiles/blob/master/dwm/etc/xdg/sxhkd/sxhkdrc#L24)
+for an example of usage with sxhkd.
+
+ dwmc setmfact +0.05
+
+Download
+--------
+* [dwm-dwmc-6.2.diff](dwm-dwmc-6.2.diff)
+
+Authors
+-------
+* Daniel Perez - <danielpza_AT_protonmail.com>
+* Chris Noxz - <chris_AT_noxz.tech> (original autor of fsignal)
Received on Sun Sep 29 2019 - 18:57:47 CEST