]> git.sur5r.net Git - i3/i3/blob - parser-specs/config.spec
Merge pull request #1909 from Airblader/feature-refactor-1
[i3/i3] / parser-specs / config.spec
1 # vim:ts=2:sw=2:expandtab
2 #
3 # i3 - an improved dynamic tiling window manager
4 # © 2009 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   'no_focus'                               -> NO_FOCUS
35   'focus_follows_mouse'                    -> FOCUS_FOLLOWS_MOUSE
36   'mouse_warping'                          -> MOUSE_WARPING
37   'force_focus_wrapping'                   -> FORCE_FOCUS_WRAPPING
38   'force_xinerama', 'force-xinerama'       -> FORCE_XINERAMA
39   'workspace_auto_back_and_forth'          -> WORKSPACE_BACK_AND_FORTH
40   'fake_outputs', 'fake-outputs'           -> FAKE_OUTPUTS
41   'force_display_urgency_hint'             -> FORCE_DISPLAY_URGENCY_HINT
42   'focus_on_window_activation'             -> FOCUS_ON_WINDOW_ACTIVATION
43   'show_marks'                             -> SHOW_MARKS
44   'workspace'                              -> WORKSPACE
45   'ipc_socket', 'ipc-socket'               -> IPC_SOCKET
46   'restart_state'                          -> RESTART_STATE
47   'popup_during_fullscreen'                -> POPUP_DURING_FULLSCREEN
48   exectype = 'exec_always', 'exec'         -> EXEC
49   colorclass = 'client.background'
50       -> COLOR_SINGLE
51   colorclass = 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
52       -> COLOR_BORDER
53
54 # We ignore comments and 'set' lines (variables).
55 state IGNORE_LINE:
56   line
57       -> INITIAL
58
59 # floating_minimum_size <width> x <height>
60 state FLOATING_MINIMUM_SIZE_WIDTH:
61   width = number
62       -> FLOATING_MINIMUM_SIZE_X
63
64 state FLOATING_MINIMUM_SIZE_X:
65   'x'
66       -> FLOATING_MINIMUM_SIZE_HEIGHT
67
68 state FLOATING_MINIMUM_SIZE_HEIGHT:
69   height = number
70       -> call cfg_floating_minimum_size(&width, &height)
71
72 # floating_maximum_size <width> x <height>
73 state FLOATING_MAXIMUM_SIZE_WIDTH:
74   width = number
75       -> FLOATING_MAXIMUM_SIZE_X
76
77 state FLOATING_MAXIMUM_SIZE_X:
78   'x'
79       -> FLOATING_MAXIMUM_SIZE_HEIGHT
80
81 state FLOATING_MAXIMUM_SIZE_HEIGHT:
82   height = number
83       -> call cfg_floating_maximum_size(&width, &height)
84
85 # floating_modifier <modifier>
86 state FLOATING_MODIFIER:
87   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl'
88       ->
89   '+'
90       ->
91   end
92       -> call cfg_floating_modifier($modifiers)
93
94 # default_orientation <horizontal|vertical|auto>
95 state DEFAULT_ORIENTATION:
96   orientation = 'horizontal', 'vertical', 'auto'
97       -> call cfg_default_orientation($orientation)
98
99 # workspace_layout <default|stacking|tabbed>
100 state WORKSPACE_LAYOUT:
101   layout = 'default', 'stacking', 'stacked', 'tabbed'
102       -> call cfg_workspace_layout($layout)
103
104 # new_window <normal|1pixel|none>
105 # new_float <normal|1pixel|none>
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 # no_focus <criteria>
153 state NO_FOCUS:
154   '['
155       -> call cfg_criteria_init(NO_FOCUS_END); CRITERIA
156
157 state NO_FOCUS_END:
158   end
159       -> call cfg_no_focus()
160
161 # Criteria: Used by for_window and assign.
162 state CRITERIA:
163   ctype = 'class'       -> CRITERION
164   ctype = 'instance'    -> CRITERION
165   ctype = 'window_role' -> CRITERION
166   ctype = 'con_id'      -> CRITERION
167   ctype = 'id'          -> CRITERION
168   ctype = 'window_type' -> CRITERION
169   ctype = 'con_mark'    -> CRITERION
170   ctype = 'title'       -> CRITERION
171   ctype = 'urgent'      -> CRITERION
172   ctype = 'workspace'   -> CRITERION
173   ']'
174       -> call cfg_criteria_pop_state()
175
176 state CRITERION:
177   '=' -> CRITERION_STR
178
179 state CRITERION_STR:
180   cvalue = word
181       -> call cfg_criteria_add($ctype, $cvalue); CRITERIA
182
183 # focus_follows_mouse bool
184 state FOCUS_FOLLOWS_MOUSE:
185   value = word
186       -> call cfg_focus_follows_mouse($value)
187
188 # mouse_warping warping_t
189 state MOUSE_WARPING:
190   value = 'none', 'output'
191       -> call cfg_mouse_warping($value)
192
193 # force_focus_wrapping
194 state FORCE_FOCUS_WRAPPING:
195   value = word
196       -> call cfg_force_focus_wrapping($value)
197
198 # force_xinerama
199 state FORCE_XINERAMA:
200   value = word
201       -> call cfg_force_xinerama($value)
202
203 # workspace_back_and_forth
204 state WORKSPACE_BACK_AND_FORTH:
205   value = word
206       -> call cfg_workspace_back_and_forth($value)
207
208
209 # fake_outputs (for testcases)
210 state FAKE_OUTPUTS:
211   outputs = string
212       -> call cfg_fake_outputs($outputs)
213
214 # force_display_urgency_hint <timeout> ms
215 state FORCE_DISPLAY_URGENCY_HINT:
216   duration_ms = number
217       -> FORCE_DISPLAY_URGENCY_HINT_MS
218
219 # show_marks
220 state SHOW_MARKS:
221   value = word
222       -> call cfg_show_marks($value)
223
224 state FORCE_DISPLAY_URGENCY_HINT_MS:
225   'ms'
226       ->
227   end
228       -> call cfg_force_display_urgency_hint(&duration_ms)
229
230 # focus_on_window_activation <smart|urgent|focus|none>
231 state FOCUS_ON_WINDOW_ACTIVATION:
232   mode = word
233       -> call cfg_focus_on_window_activation($mode)
234
235 # workspace <workspace> output <output>
236 state WORKSPACE:
237   workspace = word
238     -> WORKSPACE_OUTPUT
239
240 state WORKSPACE_OUTPUT:
241   'output'
242       -> WORKSPACE_OUTPUT_STR
243
244 state WORKSPACE_OUTPUT_STR:
245   output = word
246       -> call cfg_workspace($workspace, $output)
247
248 # ipc-socket <path>
249 state IPC_SOCKET:
250   path = string
251       -> call cfg_ipc_socket($path)
252
253 # restart_state <path> (for testcases)
254 state RESTART_STATE:
255   path = string
256       -> call cfg_restart_state($path)
257
258 # popup_during_fullscreen
259 state POPUP_DURING_FULLSCREEN:
260   value = 'ignore', 'leave_fullscreen', 'smart'
261       -> call cfg_popup_during_fullscreen($value)
262
263 # client.background <hexcolor>
264 state COLOR_SINGLE:
265   color = word
266       -> call cfg_color_single($colorclass, $color)
267
268 # colorclass border background text indicator
269 state COLOR_BORDER:
270   border = word
271       -> COLOR_BACKGROUND
272
273 state COLOR_BACKGROUND:
274   background = word
275       -> COLOR_TEXT
276
277 state COLOR_TEXT:
278   text = word
279       -> COLOR_INDICATOR
280
281 state COLOR_INDICATOR:
282   indicator = word
283       -> call cfg_color($colorclass, $border, $background, $text, $indicator)
284   end
285       -> call cfg_color($colorclass, $border, $background, $text, NULL)
286
287 # <exec|exec_always> [--no-startup-id] command
288 state EXEC:
289   no_startup_id = '--no-startup-id'
290       ->
291   command = string
292       -> call cfg_exec($exectype, $no_startup_id, $command)
293
294 # font font
295 state FONT:
296   font = string
297       -> call cfg_font($font)
298
299 # bindsym/bindcode
300 state BINDING:
301   release = '--release'
302       ->
303   border = '--border'
304       ->
305   whole_window = '--whole-window'
306       ->
307   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl', 'Mode_switch', 'Group1', 'Group2', 'Group3', 'Group4', '$mod'
308       ->
309   '+'
310       ->
311   key = word
312       -> BINDCOMMAND
313
314 state BINDCOMMAND:
315   release = '--release'
316       ->
317   border = '--border'
318       ->
319   whole_window = '--whole-window'
320       ->
321   command = string
322       -> call cfg_binding($bindtype, $modifiers, $key, $release, $border, $whole_window, $command)
323
324 ################################################################################
325 # Mode configuration
326 ################################################################################
327
328 state MODENAME:
329   modename = word
330       -> call cfg_enter_mode($modename); MODEBRACE
331
332 state MODEBRACE:
333   end
334       ->
335   '{'
336       -> MODE
337
338 state MODE:
339   end ->
340   error ->
341   '#' -> MODE_IGNORE_LINE
342   'set' -> MODE_IGNORE_LINE
343   bindtype = 'bindsym', 'bindcode', 'bind'
344       -> MODE_BINDING
345   '}'
346       -> INITIAL
347
348 # We ignore comments and 'set' lines (variables).
349 state MODE_IGNORE_LINE:
350   line
351       -> MODE
352
353 state MODE_BINDING:
354   release = '--release'
355       ->
356   border = '--border'
357       ->
358   whole_window = '--whole-window'
359       ->
360   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl', 'Mode_switch', 'Group1', 'Group2', 'Group3', 'Group4', '$mod'
361       ->
362   '+'
363       ->
364   key = word
365       -> MODE_BINDCOMMAND
366
367 state MODE_BINDCOMMAND:
368   release = '--release'
369       ->
370   border = '--border'
371       ->
372   whole_window = '--whole-window'
373       ->
374   command = string
375       -> call cfg_mode_binding($bindtype, $modifiers, $key, $release, $border, $whole_window, $command); MODE
376
377 ################################################################################
378 # Bar configuration (i3bar)
379 ################################################################################
380
381 state BARBRACE:
382   end
383       ->
384   '{'
385       -> call cfg_bar_start(); BAR
386
387 state BAR:
388   end ->
389   error ->
390   '#' -> BAR_IGNORE_LINE
391   'set' -> BAR_IGNORE_LINE
392   'i3bar_command'          -> BAR_BAR_COMMAND
393   'status_command'         -> BAR_STATUS_COMMAND
394   'socket_path'            -> BAR_SOCKET_PATH
395   'mode'                   -> BAR_MODE
396   'hidden_state'           -> BAR_HIDDEN_STATE
397   'id'                     -> BAR_ID
398   'modifier'               -> BAR_MODIFIER
399   'wheel_up_cmd'           -> BAR_WHEEL_UP_CMD
400   'wheel_down_cmd'         -> BAR_WHEEL_DOWN_CMD
401   'bindsym'                -> BAR_BINDSYM
402   'position'               -> BAR_POSITION
403   'output'                 -> BAR_OUTPUT
404   'tray_output'            -> BAR_TRAY_OUTPUT
405   'tray_padding'           -> BAR_TRAY_PADDING
406   'font'                   -> BAR_FONT
407   'separator_symbol'       -> BAR_SEPARATOR_SYMBOL
408   'binding_mode_indicator' -> BAR_BINDING_MODE_INDICATOR
409   'workspace_buttons'      -> BAR_WORKSPACE_BUTTONS
410   'strip_workspace_numbers' -> BAR_STRIP_WORKSPACE_NUMBERS
411   'verbose'                -> BAR_VERBOSE
412   'colors'                 -> BAR_COLORS_BRACE
413   '}'
414       -> call cfg_bar_finish(); INITIAL
415
416 # We ignore comments and 'set' lines (variables).
417 state BAR_IGNORE_LINE:
418   line
419       -> BAR
420
421 state BAR_BAR_COMMAND:
422   command = string
423       -> call cfg_bar_i3bar_command($command); BAR
424
425 state BAR_STATUS_COMMAND:
426   command = string
427       -> call cfg_bar_status_command($command); BAR
428
429 state BAR_SOCKET_PATH:
430   path = string
431       -> call cfg_bar_socket_path($path); BAR
432
433 state BAR_MODE:
434   mode = 'dock', 'hide', 'invisible'
435       -> call cfg_bar_mode($mode); BAR
436
437 state BAR_HIDDEN_STATE:
438   hidden_state = 'hide', 'show'
439       -> call cfg_bar_hidden_state($hidden_state); BAR
440
441 state BAR_ID:
442   bar_id = word
443       -> call cfg_bar_id($bar_id); BAR
444
445 state BAR_MODIFIER:
446   modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift'
447       -> call cfg_bar_modifier($modifier); BAR
448
449 state BAR_WHEEL_UP_CMD:
450   command = string
451       -> call cfg_bar_wheel_up_cmd($command); BAR
452
453 state BAR_WHEEL_DOWN_CMD:
454   command = string
455       -> call cfg_bar_wheel_down_cmd($command); BAR
456
457 state BAR_BINDSYM:
458   button = word
459       -> BAR_BINDSYM_COMMAND
460
461 state BAR_BINDSYM_COMMAND:
462   command = string
463       -> call cfg_bar_bindsym($button, $command); BAR
464
465 state BAR_POSITION:
466   position = 'top', 'bottom'
467       -> call cfg_bar_position($position); BAR
468
469 state BAR_OUTPUT:
470   output = string
471       -> call cfg_bar_output($output); BAR
472
473 state BAR_TRAY_OUTPUT:
474   output = word
475       -> call cfg_bar_tray_output($output); BAR
476
477 state BAR_TRAY_PADDING:
478   padding_px = number
479       -> BAR_TRAY_PADDING_PX
480
481 state BAR_TRAY_PADDING_PX:
482   'px'
483       ->
484   end
485       -> call cfg_bar_tray_padding(&padding_px); BAR
486
487 state BAR_FONT:
488   font = string
489       -> call cfg_bar_font($font); BAR
490
491 state BAR_SEPARATOR_SYMBOL:
492   separator = string
493       -> call cfg_bar_separator_symbol($separator); BAR
494
495 state BAR_BINDING_MODE_INDICATOR:
496   value = word
497       -> call cfg_bar_binding_mode_indicator($value); BAR
498
499 state BAR_WORKSPACE_BUTTONS:
500   value = word
501       -> call cfg_bar_workspace_buttons($value); BAR
502
503 state BAR_STRIP_WORKSPACE_NUMBERS:
504   value = word
505       -> call cfg_bar_strip_workspace_numbers($value); BAR
506
507 state BAR_VERBOSE:
508   value = word
509       -> call cfg_bar_verbose($value); BAR
510
511 state BAR_COLORS_BRACE:
512   end
513       ->
514   '{'
515       -> BAR_COLORS
516
517 state BAR_COLORS:
518   end ->
519   '#' -> BAR_COLORS_IGNORE_LINE
520   'set' -> BAR_COLORS_IGNORE_LINE
521   colorclass = 'background', 'statusline', 'separator'
522       -> BAR_COLORS_SINGLE
523   colorclass = 'focused_workspace', 'active_workspace', 'inactive_workspace', 'urgent_workspace', 'binding_mode'
524       -> BAR_COLORS_BORDER
525   '}'
526       -> BAR
527
528 # We ignore comments and 'set' lines (variables).
529 state BAR_COLORS_IGNORE_LINE:
530   line
531       -> BAR_COLORS
532
533 state BAR_COLORS_SINGLE:
534   color = word
535       -> call cfg_bar_color_single($colorclass, $color); BAR_COLORS
536
537 state BAR_COLORS_BORDER:
538   border = word
539       -> BAR_COLORS_BACKGROUND
540
541 state BAR_COLORS_BACKGROUND:
542   background = word
543       -> BAR_COLORS_TEXT
544
545 state BAR_COLORS_TEXT:
546   end
547       -> call cfg_bar_color($colorclass, $border, $background, NULL); BAR_COLORS
548   text = word
549       -> call cfg_bar_color($colorclass, $border, $background, $text); BAR_COLORS