Conf: Add [rules] section. (Feature #34 requested by markand CHACHA) clients option, autofree and automax option are DEPRECATED but works for some revision.
This commit is contained in:
parent
7a1bfb48f5
commit
a496d77f9e
28
src/client.c
28
src/client.c
@ -997,6 +997,8 @@ client_set_rules(Client *c)
|
||||
|
||||
XGetClassHint(dpy, c->win, &xch);
|
||||
|
||||
/* Following features is DEPRECATED, will be removed in some revision. {{{ */
|
||||
|
||||
/* Auto free */
|
||||
if(conf.client.autofree && ((xch.res_name && strstr(conf.client.autofree, xch.res_name))
|
||||
|| (xch.res_class && strstr(conf.client.autofree, xch.res_class))))
|
||||
@ -1030,6 +1032,32 @@ client_set_rules(Client *c)
|
||||
tags[c->screen][c->tag].layout.func(c->screen);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* Apply Rule if class || instance || role match */
|
||||
for(i = 0; i < conf.nrule; ++i)
|
||||
{
|
||||
if((xch.res_class && conf.rule[i].class && !strcmp(xch.res_class, conf.rule[i].class))
|
||||
|| (xch.res_name && conf.rule[i].instance && !strcmp(xch.res_name, conf.rule[i].instance)))
|
||||
{
|
||||
if(conf.rule[i].screen != -1)
|
||||
c->screen = conf.rule[i].screen;
|
||||
|
||||
if(conf.rule[i].tag != -1)
|
||||
c->tag = conf.rule[i].tag;
|
||||
|
||||
if(conf.rule[i].free)
|
||||
c->flags |= FreeFlag;
|
||||
|
||||
if(conf.rule[i].max)
|
||||
{
|
||||
client_maximize(c);
|
||||
c->flags |= MaxFlag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
33
src/config.c
33
src/config.c
@ -605,6 +605,36 @@ conf_tag_section(void)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
conf_rule_section(void)
|
||||
{
|
||||
int i;
|
||||
struct conf_sec *rules, **rule;
|
||||
|
||||
rules = fetch_section_first(NULL, "rules");
|
||||
|
||||
rule = fetch_section(rules, "rule");
|
||||
|
||||
CHECK((conf.nrule = fetch_section_count(rule)));
|
||||
|
||||
conf.rule = emalloc(conf.nrule, sizeof(Rule));
|
||||
|
||||
for(i = 0; i < conf.nrule; ++i)
|
||||
{
|
||||
conf.rule[i].class = fetch_opt_first(rule[i], "", "class").str;
|
||||
conf.rule[i].instance = fetch_opt_first(rule[i], "", "instance").str;
|
||||
conf.rule[i].role = fetch_opt_first(rule[i], "", "role").str;
|
||||
conf.rule[i].screen = fetch_opt_first(rule[i], "-1", "screen").num;
|
||||
conf.rule[i].tag = fetch_opt_first(rule[i], "-1", "tag").num;
|
||||
conf.rule[i].free = fetch_opt_first(rule[i], "false", "free").bool;
|
||||
conf.rule[i].max = fetch_opt_first(rule[i], "false", "max").bool;
|
||||
}
|
||||
|
||||
free(rule);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
conf_menu_section(void)
|
||||
{
|
||||
@ -618,7 +648,7 @@ conf_menu_section(void)
|
||||
|
||||
CHECK((conf.nmenu = fetch_section_count(set_menu)));
|
||||
|
||||
conf.menu = calloc(conf.nmenu, sizeof(Menu));
|
||||
conf.menu = emalloc(conf.nmenu, sizeof(Menu));
|
||||
|
||||
for(i = 0; i < conf.nmenu; ++i)
|
||||
{
|
||||
@ -756,6 +786,7 @@ init_conf(void)
|
||||
conf_client_section();
|
||||
conf_layout_section();
|
||||
conf_tag_section();
|
||||
conf_rule_section();
|
||||
conf_menu_section();
|
||||
conf_launcher_section();
|
||||
conf_keybind_section();
|
||||
|
||||
@ -350,8 +350,25 @@ typedef struct
|
||||
{
|
||||
char *name;
|
||||
char *content;
|
||||
char *role;
|
||||
int screen;
|
||||
int tag;
|
||||
Bool free;
|
||||
Bool max;
|
||||
} Alias;
|
||||
|
||||
/* Rule struct */
|
||||
typedef struct
|
||||
{
|
||||
char *class;
|
||||
char *instance;
|
||||
char *role;
|
||||
int screen;
|
||||
int tag;
|
||||
Bool free;
|
||||
Bool max;
|
||||
} Rule;
|
||||
|
||||
/* Configuration structure */
|
||||
typedef struct
|
||||
{
|
||||
@ -460,6 +477,7 @@ typedef struct
|
||||
Layout layout[NUM_OF_LAYOUT];
|
||||
Menu *menu;
|
||||
Launcher *launcher;
|
||||
Rule *rule;
|
||||
int *ntag;
|
||||
Bool tag_round;
|
||||
Bool client_round;
|
||||
@ -472,6 +490,7 @@ typedef struct
|
||||
int nlayout;
|
||||
int nmenu;
|
||||
int nlauncher;
|
||||
int nrule;
|
||||
} Conf;
|
||||
|
||||
typedef struct
|
||||
|
||||
@ -118,6 +118,7 @@ quit(void)
|
||||
}
|
||||
|
||||
IFREE(conf.launcher);
|
||||
IFREE(conf.rule);
|
||||
|
||||
IFREE(conf.bars.mouse);
|
||||
IFREE(conf.selbar.mouse);
|
||||
|
||||
16
wmfsrc.in
16
wmfsrc.in
@ -127,6 +127,7 @@
|
||||
#[mouse] [/mouse] Possible multi mouse section
|
||||
[/tag]
|
||||
|
||||
# clients option is *DEPRECATED* but works, see [rules] section
|
||||
[tag] name = "two" clients = {"Browser"} [/tag]
|
||||
[tag] name = "three" [/tag]
|
||||
[tag] name = "four" [/tag]
|
||||
@ -161,6 +162,7 @@
|
||||
# Modifier for mouse use
|
||||
modifier = "Alt"
|
||||
|
||||
# *DEPRECATED* but works, see [rules] section
|
||||
# Set automatic free or max client
|
||||
# autofree = "xterm|MPlayer"
|
||||
# automax = "Navigator"
|
||||
@ -195,6 +197,20 @@
|
||||
[/titlebar]
|
||||
[/client]
|
||||
|
||||
[rules]
|
||||
# Example of rule for Mplayer
|
||||
[rule]
|
||||
|
||||
class = "MPlayer" # First part of WM_CLASS
|
||||
instance = "xv" # Seconf part of WM_CLASS, not needed if first part is correct
|
||||
# role = "" # WM_WINDOW_ROLE (will be implemented)
|
||||
screen = 0 # Screen to use
|
||||
tag = 2 # Tag number of apps
|
||||
free = true # Set automatic free client
|
||||
max = false # Set automatic maximized client
|
||||
[/rule]
|
||||
[/rules]
|
||||
|
||||
[menu]
|
||||
# Default menu, binded on the root window, button 3.
|
||||
[set_menu]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user