~kris/suckless

dwm

52d7975c56557b19189c30f9b63f706083d0d19b — Kris Yotam 7 months ago 6674ef3
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
3 files changed, 29 insertions(+), 7 deletions(-)

M dwm.c
M patch/cool_autostart.c
M patches.h
M dwm.c => dwm.c +11 -5
@@ 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;

M patch/cool_autostart.c => patch/cool_autostart.c +16 -0
@@ 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();


M patches.h => patches.h +2 -2
@@ 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