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