]> git.sur5r.net Git - i3/i3/blob - include/config.h
c7748c828170223ac5dd55e1c0cd1183513a22a4
[i3/i3] / include / config.h
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  *
6  * © 2009-2010 Michael Stapelberg and contributors
7  *
8  * See file LICENSE for license information.
9  *
10  * include/config.h: Contains all structs/variables for the configurable
11  * part of i3 as well as functions handling the configuration file (calling
12  * the parser (src/cfgparse.y) with the correct path, switching key bindings
13  * mode).
14  *
15  */
16
17 #ifndef _CONFIG_H
18 #define _CONFIG_H
19
20 #include <stdbool.h>
21 #include "queue.h"
22 #include "i3.h"
23
24 typedef struct Config Config;
25 typedef struct Barconfig Barconfig;
26 extern char *current_configpath;
27 extern Config config;
28 extern SLIST_HEAD(modes_head, Mode) modes;
29 extern TAILQ_HEAD(barconfig_head, Barconfig) barconfigs;
30
31 /**
32  * Used during the config file lexing/parsing to keep the state of the lexer
33  * in order to provide useful error messages in yyerror().
34  *
35  */
36 struct context {
37     bool has_errors;
38     bool has_warnings;
39
40     int line_number;
41     char *line_copy;
42     const char *filename;
43
44     char *compact_error;
45
46     /* These are the same as in YYLTYPE */
47     int first_column;
48     int last_column;
49 };
50
51 /**
52  * Part of the struct Config. It makes sense to group colors for background,
53  * border and text as every element in i3 has them (window decorations, bar).
54  *
55  */
56 struct Colortriple {
57     uint32_t border;
58     uint32_t background;
59     uint32_t text;
60 };
61
62 /**
63  * Holds a user-assigned variable for parsing the configuration file. The key
64  * is replaced by value in every following line of the file.
65  *
66  */
67 struct Variable {
68     char *key;
69     char *value;
70     char *next_match;
71
72     SLIST_ENTRY(Variable) variables;
73 };
74
75 /**
76  * The configuration file can contain multiple sets of bindings. Apart from the
77  * default set (name == "default"), you can specify other sets and change the
78  * currently active set of bindings by using the "mode <name>" command.
79  *
80  */
81 struct Mode {
82     char *name;
83     struct bindings_head *bindings;
84
85     SLIST_ENTRY(Mode) modes;
86 };
87
88 /**
89  * Holds part of the configuration (the part which is not already in dedicated
90  * structures in include/data.h).
91  *
92  */
93 struct Config {
94     const char *terminal;
95     i3Font font;
96
97     char *ipc_socket_path;
98     const char *restart_state_path;
99
100     int default_layout;
101     int container_stack_limit;
102     int container_stack_limit_value;
103
104     /** Default orientation for new containers */
105     int default_orientation;
106
107     /** By default, focus follows mouse. If the user explicitly wants to
108      * turn this off (and instead rely only on the keyboard for changing
109      * focus), we allow him to do this with this relatively special option.
110      * It is not planned to add any different focus models. */
111     bool disable_focus_follows_mouse;
112
113     /** By default, a workspace bar is drawn at the bottom of the screen.
114      * If you want to have a more fancy bar, it is recommended to replace
115      * the whole bar by dzen2, for example using the i3-wsbar script which
116      * comes with i3. Thus, you can turn it off entirely. */
117     bool disable_workspace_bar;
118
119     /** Think of the following layout: Horizontal workspace with a tabbed
120      * con on the left of the screen and a terminal on the right of the
121      * screen. You are in the second container in the tabbed container and
122      * focus to the right. By default, i3 will set focus to the terminal on
123      * the right. If you are in the first container in the tabbed container
124      * however, focusing to the left will wrap. This option forces i3 to
125      * always wrap, which will result in you having to use "focus parent"
126      * more often. */
127     bool force_focus_wrapping;
128
129     /** By default, use the RandR API for multi-monitor setups.
130      * Unfortunately, the nVidia binary graphics driver doesn't support
131      * this API. Instead, it only support the less powerful Xinerama API,
132      * which can be enabled by this option.
133      *
134      * Note: this option takes only effect on the initial startup (eg.
135      * reconfiguration is not possible). On startup, the list of screens
136      * is fetched once and never updated. */
137     bool force_xinerama;
138
139     /** Automatic workspace back and forth switching. If this is set, a
140      * switch to the currently active workspace will switch to the
141      * previously focused one instead, making it possible to fast toggle
142      * between two workspaces. */
143     bool workspace_auto_back_and_forth;
144
145     /** The default border style for new windows. */
146     border_style_t default_border;
147
148     /** The default border style for new floating windows. */
149     border_style_t default_floating_border;
150
151     /** The modifier which needs to be pressed in combination with your mouse
152      * buttons to do things with floating windows (move, resize) */
153     uint32_t floating_modifier;
154
155     /* Color codes are stored here */
156     struct config_client {
157         uint32_t background;
158         struct Colortriple focused;
159         struct Colortriple focused_inactive;
160         struct Colortriple unfocused;
161         struct Colortriple urgent;
162     } client;
163     struct config_bar {
164         struct Colortriple focused;
165         struct Colortriple unfocused;
166         struct Colortriple urgent;
167     } bar;
168
169     /** What should happen when a new popup is opened during fullscreen mode */
170     enum {
171         PDF_LEAVE_FULLSCREEN = 0,
172         PDF_IGNORE = 1
173     } popup_during_fullscreen;
174 };
175
176 /**
177  * Holds the status bar configuration (i3bar). One of these structures is
178  * created for each 'bar' block in the config.
179  *
180  */
181 struct Barconfig {
182     /** Automatically generated ID for this bar config. Used by the bar process
183      * to request a specific configuration. */
184     char *id;
185
186     /** Number of outputs in the outputs array */
187     int num_outputs;
188     /** Outputs on which this bar should show up on. We use an array for
189      * simplicity (since we store just strings). */
190     char **outputs;
191
192     /** Output on which the tray should be shown. The special value of 'no'
193      * disables the tray (it’s enabled by default). */
194     char *tray_output;
195
196     /** Path to the i3 IPC socket. This option is discouraged since programs
197      * can find out the path by looking for the I3_SOCKET_PATH property on the
198      * root window! */
199     char *socket_path;
200
201     /** Bar display mode (hide unless modifier is pressed or show in dock mode) */
202     enum { M_DOCK = 0, M_HIDE = 1 } mode;
203
204     /** Bar position (bottom by default). */
205     enum { P_BOTTOM = 0, P_TOP = 1 } position;
206
207     /** Command that should be run to get a statusline, for example 'i3status'.
208      * Will be passed to the shell. */
209     char *status_command;
210
211     /** Font specification for all text rendered on the bar. */
212     char *font;
213
214     /** Hide workspace buttons? Configuration option is 'workspace_buttons no'
215      * but we invert the bool to get the correct default when initializing with
216      * zero. */
217     bool hide_workspace_buttons;
218
219     /** Enable verbose mode? Useful for debugging purposes. */
220     bool verbose;
221
222     struct bar_colors {
223         char *background;
224         char *statusline;
225
226         char *focused_workspace_text;
227         char *focused_workspace_bg;
228
229         char *active_workspace_text;
230         char *active_workspace_bg;
231
232         char *inactive_workspace_text;
233         char *inactive_workspace_bg;
234
235         char *urgent_workspace_text;
236         char *urgent_workspace_bg;
237     } colors;
238
239     TAILQ_ENTRY(Barconfig) configs;
240 };
241
242 /**
243  * Reads the configuration from ~/.i3/config or /etc/i3/config if not found.
244  *
245  * If you specify override_configpath, only this path is used to look for a
246  * configuration file.
247  *
248  */
249 void load_configuration(xcb_connection_t *conn, const char *override_configfile, bool reload);
250
251 /**
252  * Translates keysymbols to keycodes for all bindings which use keysyms.
253  *
254  */
255 void translate_keysyms();
256
257 /**
258  * Ungrabs all keys, to be called before re-grabbing the keys because of a
259  * mapping_notify event or a configuration file reload
260  *
261  */
262 void ungrab_all_keys(xcb_connection_t *conn);
263
264 /**
265  * Grab the bound keys (tell X to send us keypress events for those keycodes)
266  *
267  */
268 void grab_all_keys(xcb_connection_t *conn, bool bind_mode_switch);
269
270 /**
271  * Switches the key bindings to the given mode, if the mode exists
272  *
273  */
274 void switch_mode(const char *new_mode);
275
276 /**
277  * Returns a pointer to the Binding with the specified modifiers and keycode
278  * or NULL if no such binding exists.
279  *
280  */
281 Binding *get_binding(uint16_t modifiers, xcb_keycode_t keycode);
282
283 /**
284  * Kills the configerror i3-nagbar process, if any.
285  *
286  * Called when reloading/restarting.
287  *
288  * If wait_for_it is set (restarting), this function will waitpid(), otherwise,
289  * ev is assumed to handle it (reloading).
290  *
291  */
292 void kill_configerror_nagbar(bool wait_for_it);
293
294 /* prototype for src/cfgparse.y */
295 void parse_file(const char *f);
296
297 #endif