mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
autostart if autogroup empty
This commit is contained in:
parent
ac615a5407
commit
fb7a2fe253
11
calmwm.h
11
calmwm.h
@ -211,6 +211,13 @@ struct autogroupwin {
|
||||
};
|
||||
TAILQ_HEAD(autogroupwin_q, autogroupwin);
|
||||
|
||||
struct autostartcmd {
|
||||
TAILQ_ENTRY(autostartcmd) entry;
|
||||
char *cmd;
|
||||
int num;
|
||||
};
|
||||
TAILQ_HEAD(autostartcmd_q, autostartcmd);
|
||||
|
||||
struct screen_ctx {
|
||||
TAILQ_ENTRY(screen_ctx) entry;
|
||||
u_int which;
|
||||
@ -285,6 +292,7 @@ TAILQ_HEAD(menu_q, menu);
|
||||
struct conf {
|
||||
struct keybinding_q keybindingq;
|
||||
struct autogroupwin_q autogroupq;
|
||||
struct autostartcmd_q autostartq;
|
||||
struct winmatch_q ignoreq;
|
||||
char conf_path[MAXPATHLEN];
|
||||
struct cmd_q cmdq;
|
||||
@ -357,6 +365,7 @@ void group_cycle(struct screen_ctx *, int);
|
||||
void group_hidetoggle(struct screen_ctx *, int);
|
||||
void group_init(struct screen_ctx *);
|
||||
void group_make_autogroup(struct conf *, char *, int);
|
||||
void group_make_autostart(struct conf *, char *, int);
|
||||
void group_menu(XButtonEvent *);
|
||||
void group_movetogroup(struct client_ctx *, int);
|
||||
void group_only(struct screen_ctx *, int);
|
||||
@ -536,3 +545,5 @@ extern int HasXinerama, HasRandr, Randr_ev;
|
||||
extern Atom cwm_atoms[CWM_NO_ATOMS];
|
||||
|
||||
#endif /* _CALMWM_H_ */
|
||||
|
||||
#define debug(x...) fprintf(stderr, x);
|
||||
|
8
conf.c
8
conf.c
@ -201,6 +201,7 @@ conf_init(struct conf *c)
|
||||
TAILQ_INIT(&c->cmdq);
|
||||
TAILQ_INIT(&c->keybindingq);
|
||||
TAILQ_INIT(&c->autogroupq);
|
||||
TAILQ_INIT(&c->autostartq);
|
||||
TAILQ_INIT(&c->mousebindingq);
|
||||
|
||||
for (i = 0; i < nitems(kb_binds); i++)
|
||||
@ -223,6 +224,7 @@ void
|
||||
conf_clear(struct conf *c)
|
||||
{
|
||||
struct autogroupwin *ag;
|
||||
struct autostartcmd *as;
|
||||
struct keybinding *kb;
|
||||
struct winmatch *wm;
|
||||
struct cmd *cmd;
|
||||
@ -247,6 +249,12 @@ conf_clear(struct conf *c)
|
||||
xfree(ag);
|
||||
}
|
||||
|
||||
while ((as = TAILQ_FIRST(&c->autostartq)) != NULL) {
|
||||
TAILQ_REMOVE(&c->autostartq, as, entry);
|
||||
xfree(as->cmd);
|
||||
xfree(as);
|
||||
}
|
||||
|
||||
while ((wm = TAILQ_FIRST(&c->ignoreq)) != NULL) {
|
||||
TAILQ_REMOVE(&c->ignoreq, wm, entry);
|
||||
xfree(wm);
|
||||
|
25
group.c
25
group.c
@ -205,6 +205,18 @@ group_make_autogroup(struct conf *conf, char *val, int no)
|
||||
TAILQ_INSERT_TAIL(&conf->autogroupq, aw, entry);
|
||||
}
|
||||
|
||||
void
|
||||
group_make_autostart(struct conf *conf, char *cmd, int no)
|
||||
{
|
||||
struct autostartcmd *as;
|
||||
|
||||
as = xcalloc(1, sizeof(*as));
|
||||
as->cmd = xstrdup(cmd);
|
||||
as->num = no;
|
||||
|
||||
TAILQ_INSERT_TAIL(&conf->autostartq, as, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
group_setactive(struct screen_ctx *sc, long idx)
|
||||
{
|
||||
@ -288,7 +300,20 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
|
||||
err(1, "group_hidetoggle: index out of range (%d)", idx);
|
||||
|
||||
gc = &sc->groups[idx];
|
||||
|
||||
if ( TAILQ_EMPTY(&gc->clients) ) {
|
||||
struct autostartcmd *as;
|
||||
TAILQ_FOREACH(as, &Conf.autostartq, entry) {
|
||||
if ( as->num == idx + 1 ) {
|
||||
debug("run %s\n", as->cmd);
|
||||
u_spawn(as->cmd);
|
||||
}
|
||||
}
|
||||
//return;
|
||||
}
|
||||
|
||||
group_fix_hidden_state(gc);
|
||||
debug("group_hidetoggle %i\n", gc->hidden);
|
||||
|
||||
if (gc->hidden)
|
||||
group_show(sc, gc);
|
||||
|
19
parse.y
19
parse.y
@ -72,7 +72,7 @@ typedef struct {
|
||||
%token FONTNAME STICKY GAP MOUSEBIND
|
||||
%token AUTOGROUP BIND COMMAND IGNORE
|
||||
%token YES NO BORDERWIDTH MOVEAMOUNT
|
||||
%token COLOR SNAPDIST
|
||||
%token COLOR SNAPDIST AUTOSTART
|
||||
%token ACTIVEBORDER INACTIVEBORDER
|
||||
%token GROUPBORDER UNGROUPBORDER
|
||||
%token MENUBG MENUFG FONTCOLOR
|
||||
@ -141,6 +141,16 @@ main : FONTNAME STRING {
|
||||
group_make_autogroup(conf, $3, $2);
|
||||
free($3);
|
||||
}
|
||||
| AUTOSTART NUMBER STRING {
|
||||
if ($2 < 0 || $2 > CALMWM_NGROUPS) {
|
||||
free($3);
|
||||
yyerror("autostart number out of range: %d", $2);
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
group_make_autostart(conf, $3, $2);
|
||||
free($3);
|
||||
}
|
||||
| IGNORE STRING {
|
||||
struct winmatch *wm;
|
||||
|
||||
@ -234,6 +244,7 @@ lookup(char *s)
|
||||
static const struct keywords keywords[] = {
|
||||
{ "activeborder", ACTIVEBORDER},
|
||||
{ "autogroup", AUTOGROUP},
|
||||
{ "autostart", AUTOSTART},
|
||||
{ "bind", BIND},
|
||||
{ "borderwidth", BORDERWIDTH},
|
||||
{ "color", COLOR},
|
||||
@ -532,6 +543,7 @@ parse_config(const char *filename, struct conf *xconf)
|
||||
}
|
||||
else {
|
||||
struct autogroupwin *ag;
|
||||
struct autostartcmd *as;
|
||||
struct keybinding *kb;
|
||||
struct winmatch *wm;
|
||||
struct cmd *cmd;
|
||||
@ -561,6 +573,11 @@ parse_config(const char *filename, struct conf *xconf)
|
||||
TAILQ_INSERT_TAIL(&xconf->autogroupq, ag, entry);
|
||||
}
|
||||
|
||||
while ((as = TAILQ_FIRST(&conf->autostartq)) != NULL) {
|
||||
TAILQ_REMOVE(&conf->autostartq, as, entry);
|
||||
TAILQ_INSERT_TAIL(&xconf->autostartq, as, entry);
|
||||
}
|
||||
|
||||
while ((wm = TAILQ_FIRST(&conf->ignoreq)) != NULL) {
|
||||
TAILQ_REMOVE(&conf->ignoreq, wm, entry);
|
||||
TAILQ_INSERT_TAIL(&xconf->ignoreq, wm, entry);
|
||||
|
Loading…
Reference in New Issue
Block a user