dwm

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 52d7975c56557b19189c30f9b63f706083d0d19b
parent 6674ef332374efc421138f0fd4b65cf28f3045dc
Author: Kris Yotam <krisyotam@protonmail.com>
Date:   Sat, 14 Feb 2026 17:23:46 -0600

Seamless dwm renew: preserve dwmblocks, monitor state, and xresources

- Skip killing autostart processes on restart, let autostart_exec handle seamless handoff
- Enable SEAMLESS_RESTART_PATCH to persist monitor/tag state across renew
- Enable BAR_HIDEVACANTTAGS_PATCH

Diffstat:
Mdwm.c | 16+++++++++++-----
Mpatch/cool_autostart.c | 16++++++++++++++++
Mpatches.h | 4++--
3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/dwm.c b/dwm.c @@ -1327,13 +1327,19 @@ cleanup(void) #endif // SEAMLESS_RESTART_PATCH #if COOL_AUTOSTART_PATCH - /* kill child processes */ - for (i = 0; i < autostart_len; i++) { - if (0 < autostart_pids[i]) { - kill(autostart_pids[i], SIGTERM); - waitpid(autostart_pids[i], NULL, 0); + /* kill child processes, but not on restart (autostart_exec will handle it) */ + #if RESTARTSIG_PATCH + if (!restart) { + #endif // RESTARTSIG_PATCH + for (i = 0; i < autostart_len; i++) { + if (0 < autostart_pids[i]) { + kill(autostart_pids[i], SIGTERM); + waitpid(autostart_pids[i], NULL, 0); + } } + #if RESTARTSIG_PATCH } + #endif // RESTARTSIG_PATCH #endif // COOL_AUTOSTART_PATCH selmon->lt[selmon->sellt] = &foo; diff --git a/patch/cool_autostart.c b/patch/cool_autostart.c @@ -16,6 +16,22 @@ autostart_exec() autostart_pids = malloc(autostart_len * sizeof(pid_t)); for (p = autostart; *p; i++, p++) { + /* kill any existing instance before starting a new one (seamless restart) */ + FILE *cmd; + char pidline[256]; + pid_t oldpid; + int len = snprintf(pidline, sizeof(pidline), "pidof -s %s", *p); + if (len > 0 && (size_t)len < sizeof(pidline) && (cmd = popen(pidline, "r"))) { + if (fgets(pidline, sizeof(pidline), cmd)) { + oldpid = (pid_t)atol(pidline); + if (oldpid > 0) { + kill(oldpid, SIGTERM); + waitpid(oldpid, NULL, WNOHANG); + } + } + pclose(cmd); + } + if ((autostart_pids[i] = fork()) == 0) { setsid(); diff --git a/patches.h b/patches.h @@ -350,7 +350,7 @@ /* This patch prevents dwm from drawing tags with no clients (i.e. vacant) on the bar. * https://dwm.suckless.org/patches/hide_vacant_tags/ */ -#define BAR_HIDEVACANTTAGS_PATCH 0 +#define BAR_HIDEVACANTTAGS_PATCH 1 /* With this patch dwm's built-in status bar is only shown when HOLDKEY is pressed * and the bar will now overlay the display. @@ -1106,7 +1106,7 @@ * * The above is not persisted across reboots, however. */ -#define SEAMLESS_RESTART_PATCH 0 +#define SEAMLESS_RESTART_PATCH 1 /* As opposed to the original patch this only adds a rule option allowing fake fullscreen * to be enabled for applications when they start. This is intended to be used in combination