From 6c822cbfce8da235dda0a982b64e32489fb0e38e Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 18 Jan 2023 21:01:35 +0100 Subject: [PATCH 01/13] emptyview: initialising arrays to 0 is redundant --- dwm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index 9fe65b9..a0ae076 100644 --- a/dwm.c +++ b/dwm.c @@ -1594,9 +1594,7 @@ createmon(void) #endif // MONITOR_RULES_PATCH m = ecalloc(1, sizeof(Monitor)); - #if EMPTYVIEW_PATCH - m->tagset[0] = m->tagset[1] = 0; - #else + #if !EMPTYVIEW_PATCH m->tagset[0] = m->tagset[1] = 1; #endif // EMPTYVIEW_PATCH m->mfact = mfact; From 40e2cac4e97bffceabd72a937e98b40ebfd2382f Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 18 Jan 2023 21:18:14 +0100 Subject: [PATCH 02/13] pertag: simplifying implementation by removing prevtag --- dwm.c | 9 +++------ patch/pertag.c | 31 ++++++++++++------------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/dwm.c b/dwm.c index a0ae076..bb6c169 100644 --- a/dwm.c +++ b/dwm.c @@ -1687,7 +1687,7 @@ createmon(void) #if PERTAG_PATCH if (!(m->pertag = (Pertag *)calloc(1, sizeof(Pertag)))) die("fatal: could not malloc() %u bytes\n", sizeof(Pertag)); - m->pertag->curtag = m->pertag->prevtag = 1; + m->pertag->curtag = 1; for (i = 0; i <= NUMTAGS; i++) { #if FLEXTILE_DELUXE_LAYOUT m->pertag->nstacks[i] = m->nstack; @@ -4261,12 +4261,10 @@ toggleview(const Arg *arg) if (newtagset == ~0) #endif // SCRATCHPADS_PATCH { - selmon->pertag->prevtag = selmon->pertag->curtag; selmon->pertag->curtag = 0; } /* test if the user did not select the same tag */ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) { - selmon->pertag->prevtag = selmon->pertag->curtag; for (i = 0; !(newtagset & 1 << i); i++) ; selmon->pertag->curtag = i + 1; } @@ -4908,11 +4906,10 @@ view(const Arg *arg) tagpreviewswitchtag(); #endif // BAR_TAGPREVIEW_PATCH selmon->seltags ^= 1; /* toggle sel tagset */ - #if PERTAG_PATCH - pertagview(arg); - #else if (arg->ui & TAGMASK) selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; + #if PERTAG_PATCH + pertagview(arg); #endif // PERTAG_PATCH #if TAGSYNC_PATCH } diff --git a/patch/pertag.c b/patch/pertag.c index a9f5565..292076e 100644 --- a/patch/pertag.c +++ b/patch/pertag.c @@ -1,5 +1,5 @@ struct Pertag { - unsigned int curtag, prevtag; /* current and previous tag */ + unsigned int curtag; /* current tag index */ int nmasters[NUMTAGS + 1]; /* number of windows in master area */ #if FLEXTILE_DELUXE_LAYOUT int nstacks[NUMTAGS + 1]; /* number of windows in primary stack area */ @@ -29,25 +29,18 @@ void pertagview(const Arg *arg) { int i; - unsigned int tmptag; - if (arg->ui & TAGMASK) { - selmon->pertag->prevtag = selmon->pertag->curtag; - selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; - #if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH - if (arg->ui == ~SPTAGMASK) - #else - if (arg->ui == ~0) - #endif // SCRATCHPADS_PATCH - selmon->pertag->curtag = 0; - else { - for (i = 0; !(arg->ui & 1 << i); i++) ; - selmon->pertag->curtag = i + 1; - } - } else { - tmptag = selmon->pertag->prevtag; - selmon->pertag->prevtag = selmon->pertag->curtag; - selmon->pertag->curtag = tmptag; + + #if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH + if (arg->ui == ~SPTAGMASK) + #else + if (arg->ui == ~0) + #endif // SCRATCHPADS_PATCH + selmon->pertag->curtag = 0; + else { + for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++); + selmon->pertag->curtag = i + 1; } + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; #if FLEXTILE_DELUXE_LAYOUT selmon->nstack = selmon->pertag->nstacks[selmon->pertag->curtag]; From 954e60b735eb4084654d6473124d79cfa134a20b Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 18 Jan 2023 21:58:32 +0100 Subject: [PATCH 03/13] Adding proposed view history patch ref. #327 --- README.md | 7 +++++++ dwm.c | 23 +++++++++++++++++++++++ patches.def.h | 10 ++++++++++ 3 files changed, 40 insertions(+) diff --git a/README.md b/README.md index 24b0d6a..34a5f2b 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6 ### Changelog: +2023-01-18 - Added the view history patch + 2022-10-08 - Added the alt-tab patch 2022-08-12 - Added the nametag patch @@ -802,6 +804,11 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6 - adds configurable gaps between windows differentiating between outer, inner, horizontal and vertical gaps + - viewhistory + - adds a tag change history that is longer than the default current and previous tag + - `MOD`+Tab (`view(0)`) can be pressed multiple times to go further back to earlier tag + selections + - [viewontag](https://dwm.suckless.org/patches/viewontag/) - follow a window to the tag it is being moved to diff --git a/dwm.c b/dwm.c index bb6c169..91e0f2a 100644 --- a/dwm.c +++ b/dwm.c @@ -76,6 +76,7 @@ #define Button8 8 #define Button9 9 #define NUMTAGS 9 +#define NUMVIEWHIST NUMTAGS #define BARRULES 20 #if TAB_PATCH #define MAXTABS 50 @@ -487,7 +488,11 @@ struct Monitor { #endif // SETBORDERPX_PATCH unsigned int seltags; unsigned int sellt; + #if VIEW_HISTORY_PATCH + unsigned int tagset[NUMVIEWHIST]; + #else unsigned int tagset[2]; + #endif // VIEW_HISTORY_PATCH int showbar; #if TAB_PATCH int showtab; @@ -1595,7 +1600,12 @@ createmon(void) m = ecalloc(1, sizeof(Monitor)); #if !EMPTYVIEW_PATCH + #if VIEW_HISTORY_PATCH + for (i = 0; i < LENGTH(m->tagset); i++) + m->tagset[i] = 1; + #else m->tagset[0] = m->tagset[1] = 1; + #endif // VIEW_HISTORY_PATCH #endif // EMPTYVIEW_PATCH m->mfact = mfact; m->nmaster = nmaster; @@ -4905,7 +4915,20 @@ view(const Arg *arg) #if BAR_TAGPREVIEW_PATCH tagpreviewswitchtag(); #endif // BAR_TAGPREVIEW_PATCH + #if VIEW_HISTORY_PATCH + if (!arg->ui) { + selmon->seltags += 1; + if (selmon->seltags == LENGTH(selmon->tagset)) + selmon->seltags = 0; + } else { + if (selmon->seltags == 0) + selmon->seltags = LENGTH(selmon->tagset) - 1; + else + selmon->seltags -= 1; + } + #else selmon->seltags ^= 1; /* toggle sel tagset */ + #endif // VIEW_HISTORY_PATCH if (arg->ui & TAGMASK) selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; #if PERTAG_PATCH diff --git a/patches.def.h b/patches.def.h index 1429aa0..43178e2 100644 --- a/patches.def.h +++ b/patches.def.h @@ -1311,6 +1311,16 @@ */ #define VANITYGAPS_MONOCLE_PATCH 0 +/* By default MOD+Tab will take the user back to the previous tag only. If the user keeps + * using MOD+Tab then the view will switch back and forth between the current and previous tag. + * This patch allows dwm to keep a longer history of previous tag changes such that MOD+Tab can + * be pressed multiple times to go further back to earlier tag selections. + * + * The number of history elements is defined by the NUMVIEWHIST macro in dwm.c and defaults to + * the number of tags in the system. + */ +#define VIEW_HISTORY_PATCH 0 + /* Follow a window to the tag it is being moved to. * https://dwm.suckless.org/patches/viewontag/ */ From f713ddee39070ce85b5bad1ac20af497f8fae549 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 29 Jan 2023 22:13:50 +0100 Subject: [PATCH 04/13] cyclelayouts: reimplementing patch to not require the NULL layout, addresses #331 --- config.def.h | 6 ------ patch/cyclelayouts.c | 20 ++++++-------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/config.def.h b/config.def.h index e030ee9..d8741eb 100644 --- a/config.def.h +++ b/config.def.h @@ -704,9 +704,6 @@ static const Layout layouts[] = { #if NROWGRID_LAYOUT { "###", nrowgrid, {0} }, #endif - #if CYCLELAYOUTS_PATCH - { NULL, NULL, {0} }, - #endif }; #else static const Layout layouts[] = { @@ -754,9 +751,6 @@ static const Layout layouts[] = { #if NROWGRID_LAYOUT { "###", nrowgrid }, #endif - #if CYCLELAYOUTS_PATCH - { NULL, NULL }, - #endif }; #endif // FLEXTILE_DELUXE_LAYOUT diff --git a/patch/cyclelayouts.c b/patch/cyclelayouts.c index 81339bc..b8a6199 100644 --- a/patch/cyclelayouts.c +++ b/patch/cyclelayouts.c @@ -1,18 +1,10 @@ void cyclelayout(const Arg *arg) { - Layout *l; - for (l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++); - if (arg->i > 0) { - if (l->symbol && (l + 1)->symbol) - setlayout(&((Arg) { .v = (l + 1) })); - else - setlayout(&((Arg) { .v = layouts })); - } else { - if (l != layouts && (l - 1)->symbol) - setlayout(&((Arg) { .v = (l - 1) })); - else - setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] })); - } -} + int i; + int num_layouts = LENGTH(layouts); + for (i = 0; i < num_layouts && &layouts[i] != selmon->lt[selmon->sellt]; i++); + i += arg->i; + setlayout(&((Arg) { .v = &layouts[(i % num_layouts + num_layouts) % num_layouts] })); // modulo +} From 91551329e93e794001b04459a4399c074f4cf7ae Mon Sep 17 00:00:00 2001 From: bakkeby Date: Mon, 30 Jan 2023 09:45:51 +0100 Subject: [PATCH 05/13] Bump to 712d663. Use sigaction(SA_NOCLDWAIT) for SIGCHLD handling signal() semantics are pretty unclearly specified. For example, depending on OS kernel and libc, the handler may be returned to SIG_DFL (hence the inner call to read the signal handler). Moving to sigaction() means the behaviour is consistently defined. Using SA_NOCLDWAIT also allows us to avoid calling the non-reentrant function die() in the handler. Some addditional notes for archival purposes: * NRK pointed out errno of waitpid could also theoretically get clobbered. * The original patch was iterated on and modified by NRK and Hiltjo: * SIG_DFL was changed to SIG_IGN, this is required, atleast on older systems such as tested on Slackware 11. * signals are not blocked using sigprocmask, because in theory it would briefly for example also ignore a SIGTERM signal. It is OK if waitpid() is (in theory interrupted). POSIX reference: "Consequences of Process Termination": https://pubs.opengroup.org/onlinepubs/9699919799/functions/_Exit.html#tag_16_01_03_01 Ref. https://git.suckless.org/dwm/commit/712d6639ff8e863560328131bbb92b248dc9cde7.html NB: Cool autostart patch to use prior logic for now --- README.md | 2 +- dwm.c | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 34a5f2b..633f953 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This dwm 6.4 (89f9905, 2022-12-07) side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. Due to the complexity of some of the patches dwm-flexipatch has diverged from mainstream dwm by making some core patches non-optional for maintenance reasons. For the classic dwm-flexipatch build refer to branch [dwm-flexipatch-1.0](https://github.com/bakkeby/dwm-flexipatch/tree/dwm-flexipatch-1.0). +This dwm 6.4 (712d663, 2023-01-28) side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. Due to the complexity of some of the patches dwm-flexipatch has diverged from mainstream dwm by making some core patches non-optional for maintenance reasons. For the classic dwm-flexipatch build refer to branch [dwm-flexipatch-1.0](https://github.com/bakkeby/dwm-flexipatch/tree/dwm-flexipatch-1.0). For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.def.h): ```c diff --git a/dwm.c b/dwm.c index 91e0f2a..3d3eef0 100644 --- a/dwm.c +++ b/dwm.c @@ -706,8 +706,10 @@ static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); -static void showhide(Client *c); +#if COOL_AUTOSTART_PATCH static void sigchld(int unused); +#endif // COOL_AUTOSTART_PATCH +static void showhide(Client *c); static void spawn(const Arg *arg); #if RIODRAW_PATCH static pid_t spawncmd(const Arg *arg); @@ -3648,9 +3650,21 @@ setup(void) XkbStateRec xkbstate; #endif // XKB_PATCH Atom utf8string; - + #if COOL_AUTOSTART_PATCH /* clean up any zombies immediately */ sigchld(0); + #else + struct sigaction sa; + + /* do not transform children into zombies when they terminate */ + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART; + sa.sa_handler = SIG_IGN; + sigaction(SIGCHLD, &sa, NULL); + + /* clean up any zombies (inherited from .xinitrc etc) immediately */ + while (waitpid(-1, NULL, WNOHANG) > 0); + #endif // COOL_AUTOSTART_PATCH #if RESTARTSIG_PATCH signal(SIGHUP, sighup); @@ -3931,15 +3945,15 @@ showhide(Client *c) } } +#if COOL_AUTOSTART_PATCH void sigchld(int unused) { - #if COOL_AUTOSTART_PATCH pid_t pid; - #endif // COOL_AUTOSTART_PATCH + if (signal(SIGCHLD, sigchld) == SIG_ERR) die("can't install SIGCHLD handler:"); - #if COOL_AUTOSTART_PATCH + while (0 < (pid = waitpid(-1, NULL, WNOHANG))) { pid_t *p, *lim; @@ -3954,10 +3968,8 @@ sigchld(int unused) } } } - #else - while (0 < waitpid(-1, NULL, WNOHANG)); - #endif // COOL_AUTOSTART_PATCH } +#endif // COOL_AUTOSTART_PATCH #if RIODRAW_PATCH void From e424e87c40b178bf81a85e3f122824db547a56bb Mon Sep 17 00:00:00 2001 From: bakkeby Date: Thu, 2 Feb 2023 21:14:42 +0100 Subject: [PATCH 06/13] Patch toggle BAR_TITLE_LEFT_PAD_PATCH to be disabled by default ref. #335 --- patches.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches.def.h b/patches.def.h index 43178e2..59de22c 100644 --- a/patches.def.h +++ b/patches.def.h @@ -225,7 +225,7 @@ * you need it. */ #define BAR_TITLE_RIGHT_PAD_PATCH 0 -#define BAR_TITLE_LEFT_PAD_PATCH 1 +#define BAR_TITLE_LEFT_PAD_PATCH 0 /** * Bar options From e206d65f1e9c85005f290c9c2cddacf9079827b9 Mon Sep 17 00:00:00 2001 From: speedie1337 <71722170+speediegq@users.noreply.github.com> Date: Fri, 3 Feb 2023 21:04:00 +0100 Subject: [PATCH 07/13] Add swallow/window icon compatibility (#336) * Add swallow/window icon compatibility. Without this, after a client is swallowed the old icon (usually from the terminal emulator) is preserved. This is noticeable if you, say run `mpv` from a terminal emulator which is a common use case. --------- Co-authored-by: speedie --- patch/swallow.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/patch/swallow.c b/patch/swallow.c index 955d748..8a63cc0 100644 --- a/patch/swallow.c +++ b/patch/swallow.c @@ -37,6 +37,9 @@ swallow(Client *p, Client *c) XChangeProperty(dpy, c->win, netatom[NetClientList], XA_WINDOW, 32, PropModeReplace, (unsigned char *) &(p->win), 1); + #if BAR_WINICON_PATCH + updateicon(p); + #endif updatetitle(p); s = scanner ? c : p; #if BAR_EWMHTAGS_PATCH @@ -70,6 +73,9 @@ unswallow(Client *c) /* unfullscreen the client */ setfullscreen(c, 0); + #if BAR_WINICON_PATCH + updateicon(c); + #endif updatetitle(c); arrange(c->mon); XMapWindow(dpy, c->win); From c613917d6bf9f6378b9e28153116b72949555dd7 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Thu, 16 Feb 2023 10:10:02 +0100 Subject: [PATCH 08/13] config.mk - passing __XSI_VISIBLE=1 via CPPFLAGS as needed for compilation on BSD systems ref. #340 --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index 7db6cba..be145d2 100644 --- a/config.mk +++ b/config.mk @@ -60,7 +60,7 @@ INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC} ${BDINC} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS} $(BDLIBS) # flags -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D__XSI_VISIBLE=1 -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} CFLAGS = -std=c99 -pedantic -Wall -Wno-unused-function -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} LDFLAGS = ${LIBS} From fcbe686ff250849b00da2479baf71dedc3cb0f07 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 18 Feb 2023 10:31:32 +0100 Subject: [PATCH 09/13] pertag vanitygaps patch - adjust description ref. #342 --- patches.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches.def.h b/patches.def.h index 59de22c..fe1a461 100644 --- a/patches.def.h +++ b/patches.def.h @@ -874,7 +874,7 @@ */ #define PERTAG_PATCH 0 -/* Option to store gaps on a per tag basis rather than on a per monitor basis. +/* Option to enable gaps on a per tag basis rather than globally. * Depends on both pertag and vanitygaps patches being enabled. */ #define PERTAG_VANITYGAPS_PATCH 0 From 816487f4bb5773e4ba3d2644b20528c1f637b321 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 26 Mar 2023 13:00:54 +0200 Subject: [PATCH 10/13] Adding workaround for gnu core utils treating cp -n as an error ref. #347 Changes to core utils had the side effect of treating the no-clobber option as an error if the file was not copied if it already exists, thus causing make to error as well. Adding this workaround until that issue is addressed. Alternative solutions: - always overwrite the file using the -f / --force option - prefix the cp command with a hyphen which will cause make to ignore the error, but still report it - never copy dwm.desktop during the installation process --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 65c9b5a..23e899f 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ endif sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1 chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1 mkdir -p ${DESTDIR}${PREFIX}/share/xsessions - cp -n dwm.desktop ${DESTDIR}${PREFIX}/share/xsessions + test -f ${DESTDIR}${PREFIX}/share/xsessions/dwm.desktop || cp -n dwm.desktop ${DESTDIR}${PREFIX}/share/xsessions chmod 644 ${DESTDIR}${PREFIX}/share/xsessions/dwm.desktop uninstall: From 5498fed42b0135182e2facaab7ef05227cdfd726 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 9 Apr 2023 21:51:26 +0200 Subject: [PATCH 11/13] Bump to 348f655. config.mk: update to _XOPEN_SOURCE=700L SA_NOCLDWAIT is marked as XSI in the posix spec [0] and FreeBSD and NetBSD seems to more be strict about the feature test macro [1]. so update the macro to use _XOPEN_SOURCE=700L instead, which is equivalent to _POSIX_C_SOURCE=200809L except that it also unlocks the X/Open System Interfaces. [0]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html#tag_13_42 [1]: https://lists.suckless.org/dev/2302/35111.html Tested on: * NetBSD 9.3 (fixed). * FreeBSD 13 (fixed). * Void Linux musl. * Void Linux glibc. * OpenBSD 7.2 (stable). * Slackware 11. Reported-by: beastie Ref. https://git.suckless.org/dwm/commit/348f6559ab0d4793db196ffa56ba96ab95a594a6.html --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index be145d2..1e6b15d 100644 --- a/config.mk +++ b/config.mk @@ -60,7 +60,7 @@ INCS = -I${X11INC} -I${FREETYPEINC} ${YAJLINC} ${PANGOINC} ${BDINC} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${KVMLIB} ${PANGOLIB} ${YAJLLIBS} ${IMLIB2LIBS} $(BDLIBS) # flags -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D__XSI_VISIBLE=1 -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D__XSI_VISIBLE=1 -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} CFLAGS = -std=c99 -pedantic -Wall -Wno-unused-function -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} LDFLAGS = ${LIBS} From ace6f1cd88c4be23460415a815e0d29bfb7d7f07 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 9 Apr 2023 21:53:05 +0200 Subject: [PATCH 12/13] Bump to e81f17d. restore SIGCHLD sighandler to default before spawning a program From sigaction(2): A child created via fork(2) inherits a copy of its parent's signal dispositions. During an execve(2), the dispositions of handled signals are reset to the default; the dispositions of ignored signals are left unchanged. This refused to start directly some programs from configuring in config.h: static Key keys[] = { MODKEY, XK_o, spawn, {.v = cmd } }, }; Some reported programs that didn't start were: mpv, anki, dmenu_extended. Reported by pfx. Initial patch suggestion by Storkman. Ref. https://git.suckless.org/dwm/commit/e81f17d4c196aaed6893fd4beed49991caa3e2a4.html --- README.md | 2 +- dwm.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 633f953..ac9dc4a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This dwm 6.4 (712d663, 2023-01-28) side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. Due to the complexity of some of the patches dwm-flexipatch has diverged from mainstream dwm by making some core patches non-optional for maintenance reasons. For the classic dwm-flexipatch build refer to branch [dwm-flexipatch-1.0](https://github.com/bakkeby/dwm-flexipatch/tree/dwm-flexipatch-1.0). +This dwm 6.4 (e81f17d, 2023-04-09) side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. Due to the complexity of some of the patches dwm-flexipatch has diverged from mainstream dwm by making some core patches non-optional for maintenance reasons. For the classic dwm-flexipatch build refer to branch [dwm-flexipatch-1.0](https://github.com/bakkeby/dwm-flexipatch/tree/dwm-flexipatch-1.0). For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.def.h): ```c diff --git a/dwm.c b/dwm.c index 3d3eef0..f95d86d 100644 --- a/dwm.c +++ b/dwm.c @@ -3985,6 +3985,8 @@ void spawn(const Arg *arg) #endif // RIODRAW_PATCH { + struct sigaction sa; + #if RIODRAW_PATCH pid_t pid; #endif // RIODRAW_PATCH @@ -4050,6 +4052,12 @@ spawn(const Arg *arg) } #endif // SPAWNCMD_PATCH setsid(); + + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &sa, NULL); + execvp(((char **)arg->v)[0], (char **)arg->v); die("dwm: execvp '%s' failed:", ((char **)arg->v)[0]); } From 5fefbfee64fc0fa1ebe49f92979157ffa2c7c1ae Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 9 Apr 2023 22:08:41 +0200 Subject: [PATCH 13/13] cool autostart: restore SIGCHLD sighandler to default before spawning a program --- patch/cool_autostart.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/patch/cool_autostart.c b/patch/cool_autostart.c index ffd4ba3..848f5ab 100644 --- a/patch/cool_autostart.c +++ b/patch/cool_autostart.c @@ -7,6 +7,7 @@ static void autostart_exec() { const char *const *p; + struct sigaction sa; size_t i = 0; /* count entries */ @@ -17,6 +18,13 @@ autostart_exec() for (p = autostart; *p; i++, p++) { if ((autostart_pids[i] = fork()) == 0) { setsid(); + + /* Restore SIGCHLD sighandler to default before spawning a program */ + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &sa, NULL); + execvp(*p, (char *const *)p); fprintf(stderr, "dwm: execvp %s\n", *p); perror(" failed");