add autostart timestamp to avoid multiple invocations of slow apps (firefox, thunderbird, ...)

This commit is contained in:
Michael Weber 2012-06-29 10:38:54 +02:00
parent fb7a2fe253
commit b1644aa96b
2 changed files with 11 additions and 2 deletions

View File

@ -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);

12
group.c
View File

@ -29,6 +29,7 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#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;