i3
config.h
Go to the documentation of this file.
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * include/config.h: Contains all structs/variables for the configurable
8  * part of i3 as well as functions handling the configuration file (calling
9  * the parser (src/config_parse.c) with the correct path, switching key
10  * bindings mode).
11  *
12  */
13 #pragma once
14 
15 #include <stdbool.h>
16 #include "queue.h"
17 #include "i3.h"
18 #include "libi3.h"
19 
20 typedef struct Config Config;
21 typedef struct Barconfig Barconfig;
22 extern char *current_configpath;
23 extern Config config;
24 extern SLIST_HEAD(modes_head, Mode) modes;
25 extern TAILQ_HEAD(barconfig_head, Barconfig) barconfigs;
26 
32 struct context {
33  bool has_errors;
35 
37  char *line_copy;
38  const char *filename;
39 
41 
42  /* These are the same as in YYLTYPE */
45 };
46 
52 struct Colortriple {
58 };
59 
65 struct Variable {
66  char *key;
67  char *value;
68  char *next_match;
69 
70  SLIST_ENTRY(Variable) variables;
71 };
72 
79 struct Mode {
80  char *name;
82  struct bindings_head *bindings;
83 
84  SLIST_ENTRY(Mode) modes;
85 };
86 
92 struct Config {
93  const char *terminal;
95 
98 
104 
107 
113 
123 
129 
135 
145 
155 
158 
164 
171 
173  enum {
174  /* Focus if the target workspace is visible, set urgency hint otherwise. */
176  /* Always set the urgency hint. */
178  /* Always focus the window. */
180  /* Ignore the request (no focus, no urgency hint). */
181  FOWA_NONE
182  } focus_on_window_activation;
183 
187 
190 
193 
197 
203 
204  /* Color codes are stored here */
205  struct config_client {
208  struct Colortriple focused_inactive;
209  struct Colortriple unfocused;
210  struct Colortriple urgent;
211  struct Colortriple placeholder;
212  } client;
213  struct config_bar {
215  struct Colortriple unfocused;
216  struct Colortriple urgent;
217  } bar;
218 
220  enum {
221  /* display (and focus) the popup when it belongs to the fullscreen
222  * window only. */
223  PDF_SMART = 0,
224 
225  /* leave fullscreen mode unconditionally */
226  PDF_LEAVE_FULLSCREEN = 1,
227 
228  /* just ignore the popup, that is, don’t map it */
229  PDF_IGNORE = 2,
230  } popup_during_fullscreen;
231 
232  /* The number of currently parsed barconfigs */
234 };
235 
241 struct Barconfig {
244  char *id;
245 
250  char **outputs;
251 
252  /* List of outputs on which the tray is allowed to be shown, in order.
253  * The special value "none" disables it (per default, it will be shown) and
254  * the special value "primary" enabled it on the primary output. */
255  TAILQ_HEAD(tray_outputs_head, tray_output_t) tray_outputs;
256 
257  /* Padding around the tray icons. */
258  int tray_padding;
259 
263  char *socket_path;
264 
266  enum { M_DOCK = 0,
267  M_HIDE = 1,
268  M_INVISIBLE = 2 } mode;
269 
270  /* The current hidden_state of the bar, which indicates whether it is hidden or shown */
271  enum { S_HIDE = 0,
272  S_SHOW = 1 } hidden_state;
273 
275  enum {
276  M_NONE = 0,
277  M_CONTROL = 1,
278  M_SHIFT = 2,
279  M_MOD1 = 3,
280  M_MOD2 = 4,
281  M_MOD3 = 5,
282  M_MOD4 = 6,
283  M_MOD5 = 7
284  } modifier;
285 
286  TAILQ_HEAD(bar_bindings_head, Barbinding) bar_bindings;
287 
289  enum { P_BOTTOM = 0,
290  P_TOP = 1 } position;
291 
296 
300 
302  char *font;
303 
306 
311 
315 
319 
321  bool verbose;
322 
323  struct bar_colors {
324  char *background;
325  char *statusline;
326  char *separator;
327 
331 
335 
339 
343 
347 
351  } colors;
352 
353  TAILQ_ENTRY(Barconfig) configs;
354 };
355 
361 struct Barbinding {
364 
366  char *command;
367 
368  TAILQ_ENTRY(Barbinding) bindings;
369 };
370 
372  char *output;
373 
374  TAILQ_ENTRY(tray_output_t) tray_outputs;
375 };
376 
389 bool parse_configuration(const char *override_configpath, bool use_nagbar);
390 
398 void load_configuration(xcb_connection_t *conn, const char *override_configfile, bool reload);
399 
405 void ungrab_all_keys(xcb_connection_t *conn);
406 
411 void update_barconfig();
412 
422 void kill_configerror_nagbar(bool wait_for_it);
#define SLIST_HEAD(name, type)
Definition: queue.h:93
struct modes_head modes
Definition: config.c:18
char * status_command
Command that should be run to get a statusline, for example &#39;i3status&#39;.
Definition: config.h:299
Part of the struct Config.
Definition: config.h:52
layout_t
Container layouts.
Definition: data.h:84
color_t background
Definition: config.h:206
#define TAILQ_ENTRY(type)
Definition: queue.h:327
char * focused_statusline
Definition: config.h:329
char * command
The command which is to be executed for this button.
Definition: config.h:366
bool has_warnings
Definition: config.h:34
Holds part of the configuration (the part which is not already in dedicated structures in include/dat...
Definition: config.h:92
bool workspace_auto_back_and_forth
Automatic workspace back and forth switching.
Definition: config.h:163
char ** outputs
Outputs on which this bar should show up on.
Definition: config.h:250
char * inactive_workspace_bg
Definition: config.h:341
char * focused_background
Definition: config.h:328
int container_stack_limit
Definition: config.h:100
Holds a user-assigned variable for parsing the configuration file.
Definition: config.h:65
char * focused_workspace_bg
Definition: config.h:333
char * urgent_workspace_border
Definition: config.h:344
Data structure for cached font information:
Definition: libi3.h:50
char * urgent_workspace_text
Definition: config.h:346
char * urgent_workspace_bg
Definition: config.h:345
char * key
Definition: config.h:66
color_t child_border
Definition: config.h:57
struct barconfig_head barconfigs
Definition: config.c:19
int default_floating_border_width
Definition: config.h:103
xcb_connection_t * conn
XCB connection and root screen.
Definition: main.c:43
int32_t floating_minimum_width
Definition: config.h:201
Config config
Definition: config.c:17
bool disable_focus_follows_mouse
By default, focus follows mouse.
Definition: config.h:112
i3Font font
Definition: config.h:94
int32_t floating_maximum_height
Definition: config.h:200
bool strip_workspace_numbers
Strip workspace numbers? Configuration option is &#39;strip_workspace_numbers yes&#39;.
Definition: config.h:314
adjacent_t
describes if the window is adjacent to the output (physical screen) edges.
Definition: data.h:72
bool has_errors
Definition: config.h:33
bool pango_markup
Definition: config.h:81
int number_barconfigs
Definition: config.h:233
char * active_workspace_border
Definition: config.h:336
char * fake_outputs
Overwrites output detection (for testing), see src/fake_outputs.c.
Definition: config.h:157
int32_t floating_maximum_width
Maximum and minimum dimensions of a floating window.
Definition: config.h:199
bool hide_binding_mode_indicator
Hide mode button? Configuration option is &#39;binding_mode_indicator no&#39; but we invert the bool for the ...
Definition: config.h:318
void kill_configerror_nagbar(bool wait_for_it)
Kills the configerror i3-nagbar process, if any.
bool parse_configuration(const char *override_configpath, bool use_nagbar)
Finds the configuration file to use (either the one specified by override_configpath), the user’s one or the system default) and calls parse_file().
Definition: config.c:48
Definition: libi3.h:396
adjacent_t hide_edge_borders
Remove borders if they are adjacent to the screen edge.
Definition: config.h:128
float workspace_urgency_timer
By default, urgency is cleared immediately when switching to another workspace leads to focusing the ...
Definition: config.h:170
char * binding_mode_text
Definition: config.h:350
bool hide_workspace_buttons
Hide workspace buttons? Configuration option is &#39;workspace_buttons no&#39; but we invert the bool to get ...
Definition: config.h:310
#define TAILQ_HEAD(name, type)
Definition: queue.h:318
bool verbose
Enable verbose mode? Useful for debugging purposes.
Definition: config.h:321
const char * terminal
Definition: config.h:93
The configuration file can contain multiple sets of bindings.
Definition: config.h:79
char * focused_separator
Definition: config.h:330
bool show_marks
Specifies whether or not marks should be displayed in the window decoration.
Definition: config.h:186
int default_orientation
Default orientation for new containers.
Definition: config.h:106
const char * filename
Definition: config.h:38
int container_stack_limit_value
Definition: config.h:101
Holds the status bar configuration (i3bar).
Definition: config.h:241
char * output
Definition: config.h:372
char * value
Definition: config.h:67
char * focused_workspace_text
Definition: config.h:334
char * line_copy
Definition: config.h:37
bool force_xinerama
By default, use the RandR API for multi-monitor setups.
Definition: config.h:154
warping_t
Mouse pointer warping modes.
Definition: data.h:124
char * focused_workspace_border
Definition: config.h:332
char * active_workspace_text
Definition: config.h:338
int input_code
The button to be used (e.g., 1 for &quot;button1&quot;).
Definition: config.h:363
SLIST_ENTRY(Variable) variables
int first_column
Definition: config.h:43
int last_column
Definition: config.h:44
char * next_match
Definition: config.h:68
struct bindings_head * bindings
Definition: config.h:82
int32_t floating_minimum_height
Definition: config.h:202
layout_t default_layout
Definition: config.h:99
uint32_t floating_modifier
The modifier which needs to be pressed in combination with your mouse buttons to do things with float...
Definition: config.h:196
color_t indicator
Definition: config.h:56
warping_t mouse_warping
By default, when switching focus to a window on a different output (e.g.
Definition: config.h:122
char * ipc_socket_path
Definition: config.h:96
char * font
Font specification for all text rendered on the bar.
Definition: config.h:302
char * compact_error
Definition: config.h:40
void ungrab_all_keys(xcb_connection_t *conn)
Ungrabs all keys, to be called before re-grabbing the keys because of a mapping_notify event or a con...
Definition: config.c:26
color_t border
Definition: config.h:53
bool force_focus_wrapping
Think of the following layout: Horizontal workspace with a tabbed con on the left of the screen and a...
Definition: config.h:144
int num_outputs
Number of outputs in the outputs array.
Definition: config.h:247
char * current_configpath
Definition: config.c:16
char * binding_mode_border
Definition: config.h:348
border_style_t default_border
The default border style for new windows.
Definition: config.h:189
char * active_workspace_bg
Definition: config.h:337
char * inactive_workspace_text
Definition: config.h:342
bool disable_workspace_bar
By default, a workspace bar is drawn at the bottom of the screen.
Definition: config.h:134
Con * focused
Definition: tree.c:15
int line_number
Definition: config.h:36
void load_configuration(xcb_connection_t *conn, const char *override_configpath, bool reload)
Reads the configuration from ~/.i3/config or /etc/i3/config if not found.
Definition: config.c:72
void update_barconfig()
Sends the current bar configuration as an event to all barconfig_update listeners.
Definition: config.c:35
int default_border_width
Definition: config.h:102
Defines a mouse command to be executed instead of the default behavior when clicking on the non-statu...
Definition: config.h:361
color_t text
Definition: config.h:55
char * inactive_workspace_border
Definition: config.h:340
char * i3bar_command
Command that should be run to execute i3bar, give a full path if i3bar is not in your $PATH...
Definition: config.h:295
border_style_t
Definition: data.h:61
color_t background
Definition: config.h:54
char * separator_symbol
A custom separator to use instead of a vertical line.
Definition: config.h:305
border_style_t default_floating_border
The default border style for new floating windows.
Definition: config.h:192
char * id
Automatically generated ID for this bar config.
Definition: config.h:244
char * restart_state_path
Definition: config.h:97
Used during the config file lexing/parsing to keep the state of the lexer in order to provide useful ...
Definition: config.h:32
char * name
Definition: config.h:80
char * binding_mode_bg
Definition: config.h:349