Adding dwmc patch

This commit is contained in:
bakkeby 2019-10-07 23:34:23 +02:00
parent 2612060419
commit ca8638128f
9 changed files with 192 additions and 4 deletions

View File

@ -39,6 +39,7 @@ dist: clean
install: all install: all
mkdir -p ${DESTDIR}${PREFIX}/bin mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f dwm ${DESTDIR}${PREFIX}/bin cp -f dwm ${DESTDIR}${PREFIX}/bin
#cp -f patch/dwmc ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
mkdir -p ${DESTDIR}${MANPREFIX}/man1 mkdir -p ${DESTDIR}${MANPREFIX}/man1
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1 sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1

View File

@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### 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 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/) - [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/)
- lets you cycle through all your layouts - 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/) - [emptyview](https://dwm.suckless.org/patches/emptyview/)
- allows no tag at all to be selected - 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 - 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

9
dwm.c
View File

@ -2069,11 +2069,14 @@ propertynotify(XEvent *e)
} }
#endif // SYSTRAY_PATCH #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(); updatestatus();
else if (ev->state == PropertyDelete) } else if (ev->state == PropertyDelete) {
return; /* ignore */ return; /* ignore */
else if ((c = wintoclient(ev->window))) { } else if ((c = wintoclient(ev->window))) {
switch(ev->atom) { switch(ev->atom) {
default: break; default: break;
case XA_WM_TRANSIENT_FOR: case XA_WM_TRANSIENT_FOR:

40
patch/dwmc Executable file
View File

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

113
patch/dwmc.c Normal file
View File

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

13
patch/dwmc.h Normal file
View File

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

View File

@ -36,6 +36,10 @@
#include "cyclelayouts.c" #include "cyclelayouts.c"
#endif #endif
#if DWMC_PATCH
#include "dwmc.c"
#endif
#if EWMHTAGS_PATCH #if EWMHTAGS_PATCH
#include "ewmhtags.c" #include "ewmhtags.c"
#endif #endif

View File

@ -36,6 +36,10 @@
#include "cyclelayouts.h" #include "cyclelayouts.h"
#endif #endif
#if DWMC_PATCH
#include "dwmc.h"
#endif
#if EWMHTAGS_PATCH #if EWMHTAGS_PATCH
#include "ewmhtags.h" #include "ewmhtags.h"
#endif #endif

View File

@ -115,6 +115,13 @@
*/ */
#define CYCLELAYOUTS_PATCH 0 #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 /* 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 * 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. * it will be opened on the first tag.