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