diff --git a/calmwm.h b/calmwm.h index 8b796e9..7cca1da 100644 --- a/calmwm.h +++ b/calmwm.h @@ -214,6 +214,7 @@ TAILQ_HEAD(autogroupwin_q, autogroupwin); struct autostartcmd { TAILQ_ENTRY(autostartcmd) entry; char *cmd; + time_t lasttime; int num; }; TAILQ_HEAD(autostartcmd_q, autostartcmd); diff --git a/group.c b/group.c index 88f3ed3..11a8fb4 100644 --- a/group.c +++ b/group.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "calmwm.h" @@ -212,6 +213,7 @@ group_make_autostart(struct conf *conf, char *cmd, int no) as = xcalloc(1, sizeof(*as)); as->cmd = xstrdup(cmd); + as->lasttime = 0; as->num = no; TAILQ_INSERT_TAIL(&conf->autostartq, as, entry); @@ -305,8 +307,14 @@ group_hidetoggle(struct screen_ctx *sc, int idx) struct autostartcmd *as; TAILQ_FOREACH(as, &Conf.autostartq, entry) { if ( as->num == idx + 1 ) { - debug("run %s\n", as->cmd); - u_spawn(as->cmd); + time_t now = time(NULL); + if (as->lasttime < now - 5) { + debug("run %s\n", as->cmd); + as->lasttime = now; + u_spawn(as->cmd); + } else { + debug("still waiting for %s\n", as->cmd); + } } } //return;