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:
@ -62,5 +62,6 @@
|
||||
#include "move.h"
|
||||
#include "output.h"
|
||||
#include "ewmh.h"
|
||||
#include "assignments.h"
|
||||
|
||||
#endif
|
||||
|
15
include/assignments.h
Normal file
15
include/assignments.h
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* vim:ts=4:sw=4:expandtab
|
||||
*
|
||||
*/
|
||||
#ifndef _ASSIGNMENTS_H
|
||||
#define _ASSIGNMENTS_H
|
||||
|
||||
/**
|
||||
* Checks the list of assignments for the given window and runs all matching
|
||||
* ones (unless they have already been run for this specific window).
|
||||
*
|
||||
*/
|
||||
void run_assignments(i3Window *window);
|
||||
|
||||
#endif
|
@ -33,6 +33,7 @@ typedef struct Rect Rect;
|
||||
typedef struct xoutput Output;
|
||||
typedef struct Con Con;
|
||||
typedef struct Match Match;
|
||||
typedef struct Assignment Assignment;
|
||||
typedef struct Window i3Window;
|
||||
|
||||
|
||||
@ -274,11 +275,14 @@ struct Window {
|
||||
|
||||
/** Pixels the window reserves. left/right/top/bottom */
|
||||
struct reservedpx reserved;
|
||||
|
||||
/** Pointers to the Assignments which were already ran for this Window
|
||||
* (assignments run only once) */
|
||||
uint32_t nr_assignments;
|
||||
Assignment **ran_assignments;
|
||||
};
|
||||
|
||||
struct Match {
|
||||
enum { M_WINDOW, M_CON } what;
|
||||
|
||||
char *title;
|
||||
int title_len;
|
||||
char *application;
|
||||
@ -296,10 +300,6 @@ struct Match {
|
||||
Con *con_id;
|
||||
enum { M_ANY = 0, M_TILING, M_FLOATING } floating;
|
||||
|
||||
enum { M_GLOBAL = 0, M_OUTPUT, M_WORKSPACE } levels;
|
||||
|
||||
enum { M_USER = 0, M_RESTART } source;
|
||||
|
||||
char *target_ws;
|
||||
|
||||
/* Where the window looking for a match should be inserted:
|
||||
@ -317,6 +317,29 @@ struct Match {
|
||||
TAILQ_ENTRY(Match) assignments;
|
||||
};
|
||||
|
||||
struct Assignment {
|
||||
/** type of this assignment:
|
||||
*
|
||||
* A_COMMAND = run the specified command for the matching window
|
||||
* A_TO_WORKSPACE = assign the matching window to the specified workspace
|
||||
* A_TO_OUTPUT = assign the matching window to the specified output
|
||||
*
|
||||
*/
|
||||
enum { A_COMMAND = 0, A_TO_WORKSPACE = 1, A_TO_OUTPUT = 2 } type;
|
||||
|
||||
/** the criteria to check if a window matches */
|
||||
Match match;
|
||||
|
||||
/** destination workspace/output/command, depending on the type */
|
||||
union {
|
||||
char *command;
|
||||
char *workspace;
|
||||
char *output;
|
||||
} dest;
|
||||
|
||||
TAILQ_ENTRY(Assignment) real_assignments;
|
||||
};
|
||||
|
||||
struct Con {
|
||||
bool mapped;
|
||||
enum {
|
||||
|
@ -28,6 +28,7 @@ extern TAILQ_HEAD(bindings_head, Binding) *bindings;
|
||||
extern TAILQ_HEAD(autostarts_head, Autostart) autostarts;
|
||||
extern TAILQ_HEAD(assignments_head, Match) assignments;
|
||||
extern TAILQ_HEAD(ws_assignments_head, Workspace_Assignment) ws_assignments;
|
||||
extern TAILQ_HEAD(real_assignments_head, Assignment) real_assignments;
|
||||
extern SLIST_HEAD(stack_wins_head, Stack_Window) stack_wins;
|
||||
extern uint8_t root_depth;
|
||||
extern bool xcursor_supported, xkb_supported;
|
||||
|
@ -6,14 +6,14 @@
|
||||
* given window.
|
||||
*
|
||||
*/
|
||||
void window_update_class(i3Window *win, xcb_get_property_reply_t *prop);
|
||||
void window_update_class(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt);
|
||||
|
||||
/**
|
||||
* Updates the name by using _NET_WM_NAME (encoded in UTF-8) for the given
|
||||
* window. Further updates using window_update_name_legacy will be ignored.
|
||||
*
|
||||
*/
|
||||
void window_update_name(i3Window *win, xcb_get_property_reply_t *prop);
|
||||
void window_update_name(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt);
|
||||
|
||||
/**
|
||||
* Updates the name by using WM_NAME (encoded in COMPOUND_TEXT). We do not
|
||||
@ -22,7 +22,7 @@ void window_update_name(i3Window *win, xcb_get_property_reply_t *prop);
|
||||
* window_update_name()).
|
||||
*
|
||||
*/
|
||||
void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop);
|
||||
void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt);
|
||||
|
||||
/**
|
||||
* Updates the CLIENT_LEADER (logical parent window).
|
||||
|
Reference in New Issue
Block a user