From d801de46e65d18c1d35dd9c380249ee4e2dcea86 Mon Sep 17 00:00:00 2001 From: 7xnl <7xnl@proton.me> Date: Tue, 10 Sep 2024 20:25:19 +0300 Subject: [PATCH] Ignore autoruns if restarting with `restart_of_day` Currently, if restarting with the `restart_of_day` function, any autoruns in the user config file are executed again. Since the general usecase for this function is to restart spectrwm while preserving layout settings (#172, #395, #445), it doesn't make sense to execute autoruns again. --- spectrwm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spectrwm.c b/spectrwm.c index 0737202..514a8b6 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -5947,8 +5947,10 @@ restart(struct swm_screen *s, struct binding *bp, union arg *args) shutdown_cleanup(); - if (args && args->id == SWM_ARG_ID_RESTARTOFDAY) + if (args && args->id == SWM_ARG_ID_RESTARTOFDAY) { unsetenv("SWM_STARTED"); + setenv("SWM_RESTART", "YES", 1); + } execvp(start_argv[0], start_argv); warn("execvp failed"); @@ -13976,7 +13978,7 @@ setautorun(uint8_t asop, const char *selector, const char *value, int flags, (void)selector; (void)flags; - if (getenv("SWM_STARTED")) + if (getenv("SWM_STARTED") || getenv("SWM_RESTART")) return (0); if (asopcheck(asop, SWM_ASOP_BASIC, emsg)) @@ -18015,6 +18017,9 @@ main(int argc, char *argv[]) if (getenv("SWM_STARTED") == NULL) setenv("SWM_STARTED", "YES", 1); + if (getenv("SWM_RESTART")) + unsetenv("SWM_RESTART"); + /* Setup bars on all regions. */ num_screens = get_screen_count(); for (i = 0; i < num_screens; i++)