mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
add autostart timestamp to avoid multiple invocations of slow apps (firefox, thunderbird, ...)
This commit is contained in:
parent
fb7a2fe253
commit
b1644aa96b
1
calmwm.h
1
calmwm.h
@ -214,6 +214,7 @@ TAILQ_HEAD(autogroupwin_q, autogroupwin);
|
|||||||
struct autostartcmd {
|
struct autostartcmd {
|
||||||
TAILQ_ENTRY(autostartcmd) entry;
|
TAILQ_ENTRY(autostartcmd) entry;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
time_t lasttime;
|
||||||
int num;
|
int num;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(autostartcmd_q, autostartcmd);
|
TAILQ_HEAD(autostartcmd_q, autostartcmd);
|
||||||
|
12
group.c
12
group.c
@ -29,6 +29,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "calmwm.h"
|
#include "calmwm.h"
|
||||||
|
|
||||||
@ -212,6 +213,7 @@ group_make_autostart(struct conf *conf, char *cmd, int no)
|
|||||||
|
|
||||||
as = xcalloc(1, sizeof(*as));
|
as = xcalloc(1, sizeof(*as));
|
||||||
as->cmd = xstrdup(cmd);
|
as->cmd = xstrdup(cmd);
|
||||||
|
as->lasttime = 0;
|
||||||
as->num = no;
|
as->num = no;
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&conf->autostartq, as, entry);
|
TAILQ_INSERT_TAIL(&conf->autostartq, as, entry);
|
||||||
@ -305,8 +307,14 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
|
|||||||
struct autostartcmd *as;
|
struct autostartcmd *as;
|
||||||
TAILQ_FOREACH(as, &Conf.autostartq, entry) {
|
TAILQ_FOREACH(as, &Conf.autostartq, entry) {
|
||||||
if ( as->num == idx + 1 ) {
|
if ( as->num == idx + 1 ) {
|
||||||
debug("run %s\n", as->cmd);
|
time_t now = time(NULL);
|
||||||
u_spawn(as->cmd);
|
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;
|
//return;
|
||||||
|
Loading…
Reference in New Issue
Block a user