diff --git a/speedwm.c b/speedwm.c index a430448..bccacce 100644 --- a/speedwm.c +++ b/speedwm.c @@ -1010,6 +1010,16 @@ autostart_exec() { const char *const *p; size_t i = 0; + FILE *rsfile = fopen("/tmp/speedwm-isrestart", "r"); + + if (rsfile) { + /* delete autostart file and return */ + if (remove("/tmp/speedwm-isrestart")) + fprintf(stderr, "speedwm: Failed to remove /tmp/speedwm-isrestart"); + + return; + } + /* count entries */ for (p = autostart; *p; autostart_len++, p++) while (*++p); @@ -4365,8 +4375,20 @@ quit(const Arg *arg) } } - if(arg->i) restart = 1; - running = 0; + /* it will not be 0 because 0 means exit, not restart */ + if (arg->i) { + restart = 1; + + FILE *rsfile = fopen("/tmp/speedwm-isrestart", "w"); + int ws = fputs("\n", rsfile); + + if (ws) + fprintf(stderr, "speedwm: failed to write restart file.\n"); + + fclose(rsfile); + } + + running = 0; } Client * @@ -6499,8 +6521,7 @@ main(int argc, char *argv[]) system("[ -e $HOME/.config/speedwm/speedwmrc ] && xrdb -override $HOME/.config/speedwm/speedwmrc"); /* autostart */ - if (!restart) - autostart_exec(); + autostart_exec(); /* load colors */ #if USEXRESOURCES