]> git.sur5r.net Git - i3/i3/blob - parser-specs/config.spec
Merge pull request #1613 from Airblader/feature-1426
[i3/i3] / parser-specs / config.spec
1 # vim:ts=2:sw=2:expandtab
2 #
3 # i3 - an improved dynamic tiling window manager
4 # © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
5 #
6 # parser-specs/config.spec: Specification file for generate-command-parser.pl
7 # which will generate the appropriate header files for our C parser.
8 #
9 # Use :source highlighting.vim in vim to get syntax highlighting
10 # for this file.
11
12 # TODO: should we implement an include statement for the criteria part so we DRY?
13
14 state INITIAL:
15   # We have an end token here for all the commands which just call some
16   # function without using an explicit 'end' token.
17   end ->
18   error ->
19   '#'                                      -> IGNORE_LINE
20   'set'                                    -> IGNORE_LINE
21   bindtype = 'bindsym', 'bindcode', 'bind' -> BINDING
22   'bar'                                    -> BARBRACE
23   'font'                                   -> FONT
24   'mode'                                   -> MODENAME
25   'floating_minimum_size'                  -> FLOATING_MINIMUM_SIZE_WIDTH
26   'floating_maximum_size'                  -> FLOATING_MAXIMUM_SIZE_WIDTH
27   'floating_modifier'                      -> FLOATING_MODIFIER
28   'default_orientation'                    -> DEFAULT_ORIENTATION
29   'workspace_layout'                       -> WORKSPACE_LAYOUT
30   windowtype = 'new_window', 'new_float'   -> NEW_WINDOW
31   'hide_edge_borders'                      -> HIDE_EDGE_BORDERS
32   'for_window'                             -> FOR_WINDOW
33   'assign'                                 -> ASSIGN
34   'focus_follows_mouse'                    -> FOCUS_FOLLOWS_MOUSE
35   'mouse_warping'                          -> MOUSE_WARPING
36   'force_focus_wrapping'                   -> FORCE_FOCUS_WRAPPING
37   'force_xinerama', 'force-xinerama'       -> FORCE_XINERAMA
38   'workspace_auto_back_and_forth'          -> WORKSPACE_BACK_AND_FORTH
39   'fake_outputs', 'fake-outputs'           -> FAKE_OUTPUTS
40   'force_display_urgency_hint'             -> FORCE_DISPLAY_URGENCY_HINT
41   'focus_on_window_activation'             -> FOCUS_ON_WINDOW_ACTIVATION
42   'workspace'                              -> WORKSPACE
43   'ipc_socket', 'ipc-socket'               -> IPC_SOCKET
44   'restart_state'                          -> RESTART_STATE
45   'popup_during_fullscreen'                -> POPUP_DURING_FULLSCREEN
46   exectype = 'exec_always', 'exec'         -> EXEC
47   colorclass = 'client.background'
48       -> COLOR_SINGLE
49   colorclass = 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
50       -> COLOR_BORDER
51
52 # We ignore comments and 'set' lines (variables).
53 state IGNORE_LINE:
54   line
55       -> INITIAL
56
57 # floating_minimum_size <width> x <height>
58 state FLOATING_MINIMUM_SIZE_WIDTH:
59   width = number
60       -> FLOATING_MINIMUM_SIZE_X
61
62 state FLOATING_MINIMUM_SIZE_X:
63   'x'
64       -> FLOATING_MINIMUM_SIZE_HEIGHT
65
66 state FLOATING_MINIMUM_SIZE_HEIGHT:
67   height = number
68       -> call cfg_floating_minimum_size(&width, &height)
69
70 # floating_maximum_size <width> x <height>
71 state FLOATING_MAXIMUM_SIZE_WIDTH:
72   width = number
73       -> FLOATING_MAXIMUM_SIZE_X
74
75 state FLOATING_MAXIMUM_SIZE_X:
76   'x'
77       -> FLOATING_MAXIMUM_SIZE_HEIGHT
78
79 state FLOATING_MAXIMUM_SIZE_HEIGHT:
80   height = number
81       -> call cfg_floating_maximum_size(&width, &height)
82
83 # floating_modifier <modifier>
84 state FLOATING_MODIFIER:
85   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl'
86       ->
87   '+'
88       ->
89   end
90       -> call cfg_floating_modifier($modifiers)
91
92 # default_orientation <horizontal|vertical|auto>
93 state DEFAULT_ORIENTATION:
94   orientation = 'horizontal', 'vertical', 'auto'
95       -> call cfg_default_orientation($orientation)
96
97 # workspace_layout <default|stacking|tabbed>
98 state WORKSPACE_LAYOUT:
99   layout = 'default', 'stacking', 'stacked', 'tabbed'
100       -> call cfg_workspace_layout($layout)
101
102 # new_window <normal|1pixel|none>
103 # new_float <normal|1pixel|none>
104 # TODO: new_float is not in the userguide yet
105 # TODO: pixel is not in the userguide yet
106 state NEW_WINDOW:
107   border = 'normal', 'pixel'
108       -> NEW_WINDOW_PIXELS
109   border = '1pixel', 'none'
110       -> call cfg_new_window($windowtype, $border, -1)
111
112 state NEW_WINDOW_PIXELS:
113   end
114       -> call cfg_new_window($windowtype, $border, 2)
115   width = number
116       -> NEW_WINDOW_PIXELS_PX
117
118 state NEW_WINDOW_PIXELS_PX:
119   'px'
120       ->
121   end
122       -> call cfg_new_window($windowtype, $border, &width)
123
124 # hide_edge_borders <none|vertical|horizontal|both>
125 # also hide_edge_borders <bool> for compatibility
126 state HIDE_EDGE_BORDERS:
127   hide_borders = 'none', 'vertical', 'horizontal', 'both'
128       -> call cfg_hide_edge_borders($hide_borders)
129   hide_borders = '1', 'yes', 'true', 'on', 'enable', 'active'
130       -> call cfg_hide_edge_borders($hide_borders)
131
132 # for_window <criteria> command
133 state FOR_WINDOW:
134   '['
135       -> call cfg_criteria_init(FOR_WINDOW_COMMAND); CRITERIA
136
137 state FOR_WINDOW_COMMAND:
138   command = string
139       -> call cfg_for_window($command)
140
141 # assign <criteria> [→] workspace
142 state ASSIGN:
143   '['
144       -> call cfg_criteria_init(ASSIGN_WORKSPACE); CRITERIA
145
146 state ASSIGN_WORKSPACE:
147   '→'
148       ->
149   workspace = string
150       -> call cfg_assign($workspace)
151
152 # Criteria: Used by for_window and assign.
153 state CRITERIA:
154   ctype = 'class'       -> CRITERION
155   ctype = 'instance'    -> CRITERION
156   ctype = 'window_role' -> CRITERION
157   ctype = 'con_id'      -> CRITERION
158   ctype = 'id'          -> CRITERION
159   ctype = 'con_mark'    -> CRITERION
160   ctype = 'title'       -> CRITERION
161   ctype = 'urgent'      -> CRITERION
162   ']'
163       -> call cfg_criteria_pop_state()
164
165 state CRITERION:
166   '=' -> CRITERION_STR
167
168 state CRITERION_STR:
169   cvalue = word
170       -> call cfg_criteria_add($ctype, $cvalue); CRITERIA
171
172 # focus_follows_mouse bool
173 state FOCUS_FOLLOWS_MOUSE:
174   value = word
175       -> call cfg_focus_follows_mouse($value)
176
177 # mouse_warping warping_t
178 state MOUSE_WARPING:
179   value = 'none', 'output'
180       -> call cfg_mouse_warping($value)
181
182 # force_focus_wrapping
183 state FORCE_FOCUS_WRAPPING:
184   value = word
185       -> call cfg_force_focus_wrapping($value)
186
187 # force_xinerama
188 state FORCE_XINERAMA:
189   value = word
190       -> call cfg_force_xinerama($value)
191
192 # workspace_back_and_forth
193 state WORKSPACE_BACK_AND_FORTH:
194   value = word
195       -> call cfg_workspace_back_and_forth($value)
196
197
198 # fake_outputs (for testcases)
199 state FAKE_OUTPUTS:
200   outputs = string
201       -> call cfg_fake_outputs($outputs)
202
203 # force_display_urgency_hint <timeout> ms
204 state FORCE_DISPLAY_URGENCY_HINT:
205   duration_ms = number
206       -> FORCE_DISPLAY_URGENCY_HINT_MS
207
208 state FORCE_DISPLAY_URGENCY_HINT_MS:
209   'ms'
210       ->
211   end
212       -> call cfg_force_display_urgency_hint(&duration_ms)
213
214 # focus_on_window_activation <smart|urgent|focus|none>
215 state FOCUS_ON_WINDOW_ACTIVATION:
216   mode = word
217       -> call cfg_focus_on_window_activation($mode)
218
219 # workspace <workspace> output <output>
220 state WORKSPACE:
221   workspace = word
222     -> WORKSPACE_OUTPUT
223
224 state WORKSPACE_OUTPUT:
225   'output'
226       -> WORKSPACE_OUTPUT_STR
227
228 state WORKSPACE_OUTPUT_STR:
229   output = word
230       -> call cfg_workspace($workspace, $output)
231
232 # ipc-socket <path>
233 state IPC_SOCKET:
234   path = string
235       -> call cfg_ipc_socket($path)
236
237 # restart_state <path> (for testcases)
238 state RESTART_STATE:
239   path = string
240       -> call cfg_restart_state($path)
241
242 # popup_during_fullscreen
243 state POPUP_DURING_FULLSCREEN:
244   value = 'ignore', 'leave_fullscreen', 'smart'
245       -> call cfg_popup_during_fullscreen($value)
246
247 # client.background <hexcolor>
248 state COLOR_SINGLE:
249   color = word
250       -> call cfg_color_single($colorclass, $color)
251
252 # colorclass border background text indicator
253 state COLOR_BORDER:
254   border = word
255       -> COLOR_BACKGROUND
256
257 state COLOR_BACKGROUND:
258   background = word
259       -> COLOR_TEXT
260
261 state COLOR_TEXT:
262   text = word
263       -> COLOR_INDICATOR
264
265 state COLOR_INDICATOR:
266   indicator = word
267       -> call cfg_color($colorclass, $border, $background, $text, $indicator)
268   end
269       -> call cfg_color($colorclass, $border, $background, $text, NULL)
270
271 # <exec|exec_always> [--no-startup-id] command
272 state EXEC:
273   no_startup_id = '--no-startup-id'
274       ->
275   command = string
276       -> call cfg_exec($exectype, $no_startup_id, $command)
277
278 # font font
279 state FONT:
280   font = string
281       -> call cfg_font($font)
282
283 # bindsym/bindcode
284 state BINDING:
285   release = '--release'
286       ->
287   whole_window = '--whole-window'
288       ->
289   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl', 'Mode_switch', '$mod'
290       ->
291   '+'
292       ->
293   key = word
294       -> BINDCOMMAND
295
296 state BINDCOMMAND:
297   release = '--release'
298       ->
299   whole_window = '--whole-window'
300       ->
301   command = string
302       -> call cfg_binding($bindtype, $modifiers, $key, $release, $whole_window, $command)
303
304 ################################################################################
305 # Mode configuration
306 ################################################################################
307
308 state MODENAME:
309   modename = word
310       -> call cfg_enter_mode($modename); MODEBRACE
311
312 state MODEBRACE:
313   end
314       ->
315   '{'
316       -> MODE
317
318 state MODE:
319   end ->
320   error ->
321   '#' -> MODE_IGNORE_LINE
322   'set' -> MODE_IGNORE_LINE
323   bindtype = 'bindsym', 'bindcode', 'bind'
324       -> MODE_BINDING
325   '}'
326       -> INITIAL
327
328 # We ignore comments and 'set' lines (variables).
329 state MODE_IGNORE_LINE:
330   line
331       -> MODE
332
333 state MODE_BINDING:
334   release = '--release'
335       ->
336   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl', 'Mode_switch', '$mod'
337       ->
338   '+'
339       ->
340   key = word
341       -> MODE_BINDCOMMAND
342
343 state MODE_BINDCOMMAND:
344   release = '--release'
345       ->
346   whole_window = '--whole-window'
347       ->
348   command = string
349       -> call cfg_mode_binding($bindtype, $modifiers, $key, $release, $whole_window, $command); MODE
350
351 ################################################################################
352 # Bar configuration (i3bar)
353 ################################################################################
354
355 state BARBRACE:
356   end
357       ->
358   '{'
359       -> BAR
360
361 state BAR:
362   end ->
363   error ->
364   '#' -> BAR_IGNORE_LINE
365   'set' -> BAR_IGNORE_LINE
366   'i3bar_command'          -> BAR_BAR_COMMAND
367   'status_command'         -> BAR_STATUS_COMMAND
368   'socket_path'            -> BAR_SOCKET_PATH
369   'mode'                   -> BAR_MODE
370   'hidden_state'           -> BAR_HIDDEN_STATE
371   'id'                     -> BAR_ID
372   'modifier'               -> BAR_MODIFIER
373   'wheel_up_cmd'           -> BAR_WHEEL_UP_CMD
374   'wheel_down_cmd'         -> BAR_WHEEL_DOWN_CMD
375   'position'               -> BAR_POSITION
376   'output'                 -> BAR_OUTPUT
377   'tray_output'            -> BAR_TRAY_OUTPUT
378   'font'                   -> BAR_FONT
379   'separator_symbol'       -> BAR_SEPARATOR_SYMBOL
380   'binding_mode_indicator' -> BAR_BINDING_MODE_INDICATOR
381   'workspace_buttons'      -> BAR_WORKSPACE_BUTTONS
382   'strip_workspace_numbers' -> BAR_STRIP_WORKSPACE_NUMBERS
383   'verbose'                -> BAR_VERBOSE
384   'colors'                 -> BAR_COLORS_BRACE
385   '}'
386       -> call cfg_bar_finish(); INITIAL
387
388 # We ignore comments and 'set' lines (variables).
389 state BAR_IGNORE_LINE:
390   line
391       -> BAR
392
393 state BAR_BAR_COMMAND:
394   command = string
395       -> call cfg_bar_i3bar_command($command); BAR
396
397 state BAR_STATUS_COMMAND:
398   command = string
399       -> call cfg_bar_status_command($command); BAR
400
401 state BAR_SOCKET_PATH:
402   path = string
403       -> call cfg_bar_socket_path($path); BAR
404
405 state BAR_MODE:
406   mode = 'dock', 'hide', 'invisible'
407       -> call cfg_bar_mode($mode); BAR
408
409 state BAR_HIDDEN_STATE:
410   hidden_state = 'hide', 'show'
411       -> call cfg_bar_hidden_state($hidden_state); BAR
412
413 state BAR_ID:
414   bar_id = word
415       -> call cfg_bar_id($bar_id); BAR
416
417 state BAR_MODIFIER:
418   modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift'
419       -> call cfg_bar_modifier($modifier); BAR
420
421 state BAR_WHEEL_UP_CMD:
422   command = string
423       -> call cfg_bar_wheel_up_cmd($command); BAR
424
425 state BAR_WHEEL_DOWN_CMD:
426   command = string
427       -> call cfg_bar_wheel_down_cmd($command); BAR
428
429 state BAR_POSITION:
430   position = 'top', 'bottom'
431       -> call cfg_bar_position($position); BAR
432
433 state BAR_OUTPUT:
434   output = string
435       -> call cfg_bar_output($output); BAR
436
437 state BAR_TRAY_OUTPUT:
438   output = word
439       -> call cfg_bar_tray_output($output); BAR
440
441 state BAR_FONT:
442   font = string
443       -> call cfg_bar_font($font); BAR
444
445 state BAR_SEPARATOR_SYMBOL:
446   separator = string
447       -> call cfg_bar_separator_symbol($separator); BAR
448
449 state BAR_BINDING_MODE_INDICATOR:
450   value = word
451       -> call cfg_bar_binding_mode_indicator($value); BAR
452
453 state BAR_WORKSPACE_BUTTONS:
454   value = word
455       -> call cfg_bar_workspace_buttons($value); BAR
456
457 state BAR_STRIP_WORKSPACE_NUMBERS:
458   value = word
459       -> call cfg_bar_strip_workspace_numbers($value); BAR
460
461 state BAR_VERBOSE:
462   value = word
463       -> call cfg_bar_verbose($value); BAR
464
465 state BAR_COLORS_BRACE:
466   end
467       ->
468   '{'
469       -> BAR_COLORS
470
471 state BAR_COLORS:
472   end ->
473   '#' -> BAR_COLORS_IGNORE_LINE
474   'set' -> BAR_COLORS_IGNORE_LINE
475   colorclass = 'background', 'statusline', 'separator'
476       -> BAR_COLORS_SINGLE
477   colorclass = 'focused_workspace', 'active_workspace', 'inactive_workspace', 'urgent_workspace'
478       -> BAR_COLORS_BORDER
479   '}'
480       -> BAR
481
482 # We ignore comments and 'set' lines (variables).
483 state BAR_COLORS_IGNORE_LINE:
484   line
485       -> BAR_COLORS
486
487 state BAR_COLORS_SINGLE:
488   color = word
489       -> call cfg_bar_color_single($colorclass, $color); BAR_COLORS
490
491 state BAR_COLORS_BORDER:
492   border = word
493       -> BAR_COLORS_BACKGROUND
494
495 state BAR_COLORS_BACKGROUND:
496   background = word
497       -> BAR_COLORS_TEXT
498
499 state BAR_COLORS_TEXT:
500   end
501       -> call cfg_bar_color($colorclass, $border, $background, NULL); BAR_COLORS
502   text = word
503       -> call cfg_bar_color($colorclass, $border, $background, $text); BAR_COLORS