Time Lord technology: for_window config directive to run arbitrary cmds
An example to set all XTerms floating: for_window [class="XTerm"] mode floating To make all urxvts use a 1-pixel border: for_window [class="urxvt"] border 1pixel A less useful, but rather funny example: for_window [title="x200: ~/work"] mode floating The commands are not completely arbitrary. The commands above were tested, others may need some fixing. Internally, windows are compared against your criteria (class, title, …) when they are initially managed and whenever one of the relevant values change. Then, the specified command is run *once* (per window). It gets prefixed with a criteria to make it match only the specific window that triggered it. So, if you configure "mode floating", i3 runs something like '[id="8393923"] mode floating'.
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
* vim:ts=4:sw=4:expandtab
|
||||
*
|
||||
* i3 - an improved dynamic tiling window manager
|
||||
* © 2009-2010 Michael Stapelberg and contributors (see also: LICENSE)
|
||||
* © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
|
||||
*
|
||||
* cmdparse.y: the parser for commands you send to i3 (or bind on keys)
|
||||
*
|
||||
@ -80,6 +80,7 @@ int cmdyywrap() {
|
||||
}
|
||||
|
||||
char *parse_cmd(const char *new) {
|
||||
LOG("COMMAND: *%s*\n", new);
|
||||
cmdyy_scan_string(new);
|
||||
|
||||
match_init(¤t_match);
|
||||
@ -512,15 +513,21 @@ direction:
|
||||
mode:
|
||||
TOK_MODE WHITESPACE window_mode
|
||||
{
|
||||
if ($3 == TOK_TOGGLE) {
|
||||
printf("should toggle mode\n");
|
||||
toggle_floating_mode(focused, false);
|
||||
} else {
|
||||
printf("should switch mode to %s\n", ($3 == TOK_FLOATING ? "floating" : "tiling"));
|
||||
if ($3 == TOK_FLOATING) {
|
||||
floating_enable(focused, false);
|
||||
HANDLE_EMPTY_MATCH;
|
||||
|
||||
owindow *current;
|
||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||
printf("matching: %p / %s\n", current->con, current->con->name);
|
||||
if ($3 == TOK_TOGGLE) {
|
||||
printf("should toggle mode\n");
|
||||
toggle_floating_mode(current->con, false);
|
||||
} else {
|
||||
floating_disable(focused, false);
|
||||
printf("should switch mode to %s\n", ($3 == TOK_FLOATING ? "floating" : "tiling"));
|
||||
if ($3 == TOK_FLOATING) {
|
||||
floating_enable(current->con, false);
|
||||
} else {
|
||||
floating_disable(current->con, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -608,11 +615,14 @@ layout:
|
||||
printf("changing layout to %d\n", $3);
|
||||
owindow *current;
|
||||
|
||||
HANDLE_EMPTY_MATCH;
|
||||
|
||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||
printf("matching: %p / %s\n", current->con, current->con->name);
|
||||
con_set_layout(current->con, $3);
|
||||
/* check if the match is empty, not if the result is empty */
|
||||
if (match_is_empty(¤t_match))
|
||||
con_set_layout(focused->parent, $3);
|
||||
else {
|
||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||
printf("matching: %p / %s\n", current->con, current->con->name);
|
||||
con_set_layout(current->con, $3);
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
|
Reference in New Issue
Block a user