]> git.sur5r.net Git - i3/i3/blob - parser-specs/config.spec
Merge pull request #1638 from hwangcc23/fix-1489
[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   'delay_exit_on_zero_displays'            -> DELAY_EXIT_ON_ZERO_DISPLAYS
43   'focus_on_window_activation'             -> FOCUS_ON_WINDOW_ACTIVATION
44   'show_marks'                             -> SHOW_MARKS
45   'workspace'                              -> WORKSPACE
46   'ipc_socket', 'ipc-socket'               -> IPC_SOCKET
47   'restart_state'                          -> RESTART_STATE
48   'popup_during_fullscreen'                -> POPUP_DURING_FULLSCREEN
49   exectype = 'exec_always', 'exec'         -> EXEC
50   colorclass = 'client.background'
51       -> COLOR_SINGLE
52   colorclass = 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
53       -> COLOR_BORDER
54
55 # We ignore comments and 'set' lines (variables).
56 state IGNORE_LINE:
57   line
58       -> INITIAL
59
60 # floating_minimum_size <width> x <height>
61 state FLOATING_MINIMUM_SIZE_WIDTH:
62   width = number
63       -> FLOATING_MINIMUM_SIZE_X
64
65 state FLOATING_MINIMUM_SIZE_X:
66   'x'
67       -> FLOATING_MINIMUM_SIZE_HEIGHT
68
69 state FLOATING_MINIMUM_SIZE_HEIGHT:
70   height = number
71       -> call cfg_floating_minimum_size(&width, &height)
72
73 # floating_maximum_size <width> x <height>
74 state FLOATING_MAXIMUM_SIZE_WIDTH:
75   width = number
76       -> FLOATING_MAXIMUM_SIZE_X
77
78 state FLOATING_MAXIMUM_SIZE_X:
79   'x'
80       -> FLOATING_MAXIMUM_SIZE_HEIGHT
81
82 state FLOATING_MAXIMUM_SIZE_HEIGHT:
83   height = number
84       -> call cfg_floating_maximum_size(&width, &height)
85
86 # floating_modifier <modifier>
87 state FLOATING_MODIFIER:
88   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl'
89       ->
90   '+'
91       ->
92   end
93       -> call cfg_floating_modifier($modifiers)
94
95 # default_orientation <horizontal|vertical|auto>
96 state DEFAULT_ORIENTATION:
97   orientation = 'horizontal', 'vertical', 'auto'
98       -> call cfg_default_orientation($orientation)
99
100 # workspace_layout <default|stacking|tabbed>
101 state WORKSPACE_LAYOUT:
102   layout = 'default', 'stacking', 'stacked', 'tabbed'
103       -> call cfg_workspace_layout($layout)
104
105 # new_window <normal|1pixel|none>
106 # new_float <normal|1pixel|none>
107 # TODO: new_float is not in the userguide yet
108 # TODO: pixel is not in the userguide yet
109 state NEW_WINDOW:
110   border = 'normal', 'pixel'
111       -> NEW_WINDOW_PIXELS
112   border = '1pixel', 'none'
113       -> call cfg_new_window($windowtype, $border, -1)
114
115 state NEW_WINDOW_PIXELS:
116   end
117       -> call cfg_new_window($windowtype, $border, 2)
118   width = number
119       -> NEW_WINDOW_PIXELS_PX
120
121 state NEW_WINDOW_PIXELS_PX:
122   'px'
123       ->
124   end
125       -> call cfg_new_window($windowtype, $border, &width)
126
127 # hide_edge_borders <none|vertical|horizontal|both>
128 # also hide_edge_borders <bool> for compatibility
129 state HIDE_EDGE_BORDERS:
130   hide_borders = 'none', 'vertical', 'horizontal', 'both'
131       -> call cfg_hide_edge_borders($hide_borders)
132   hide_borders = '1', 'yes', 'true', 'on', 'enable', 'active'
133       -> call cfg_hide_edge_borders($hide_borders)
134
135 # for_window <criteria> command
136 state FOR_WINDOW:
137   '['
138       -> call cfg_criteria_init(FOR_WINDOW_COMMAND); CRITERIA
139
140 state FOR_WINDOW_COMMAND:
141   command = string
142       -> call cfg_for_window($command)
143
144 # assign <criteria> [→] workspace
145 state ASSIGN:
146   '['
147       -> call cfg_criteria_init(ASSIGN_WORKSPACE); CRITERIA
148
149 state ASSIGN_WORKSPACE:
150   '→'
151       ->
152   workspace = string
153       -> call cfg_assign($workspace)
154
155 # no_focus <criteria>
156 state NO_FOCUS:
157   '['
158       -> call cfg_criteria_init(NO_FOCUS_END); CRITERIA
159
160 state NO_FOCUS_END:
161   end
162       -> call cfg_no_focus()
163
164 # Criteria: Used by for_window and assign.
165 state CRITERIA:
166   ctype = 'class'       -> CRITERION
167   ctype = 'instance'    -> CRITERION
168   ctype = 'window_role' -> CRITERION
169   ctype = 'con_id'      -> CRITERION
170   ctype = 'id'          -> CRITERION
171   ctype = 'window_type' -> CRITERION
172   ctype = 'con_mark'    -> CRITERION
173   ctype = 'title'       -> CRITERION
174   ctype = 'urgent'      -> 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 # delay_exit_on_zero_displays <delay> ms
233 state DELAY_EXIT_ON_ZERO_DISPLAYS:
234   duration_ms = number
235       -> DELAY_EXIT_ON_ZERO_DISPLAYS_MS
236
237 state DELAY_EXIT_ON_ZERO_DISPLAYS_MS:
238   'ms'
239       ->
240   end
241       -> call cfg_delay_exit_on_zero_displays(&duration_ms)
242
243 # focus_on_window_activation <smart|urgent|focus|none>
244 state FOCUS_ON_WINDOW_ACTIVATION:
245   mode = word
246       -> call cfg_focus_on_window_activation($mode)
247
248 # workspace <workspace> output <output>
249 state WORKSPACE:
250   workspace = word
251     -> WORKSPACE_OUTPUT
252
253 state WORKSPACE_OUTPUT:
254   'output'
255       -> WORKSPACE_OUTPUT_STR
256
257 state WORKSPACE_OUTPUT_STR:
258   output = word
259       -> call cfg_workspace($workspace, $output)
260
261 # ipc-socket <path>
262 state IPC_SOCKET:
263   path = string
264       -> call cfg_ipc_socket($path)
265
266 # restart_state <path> (for testcases)
267 state RESTART_STATE:
268   path = string
269       -> call cfg_restart_state($path)
270
271 # popup_during_fullscreen
272 state POPUP_DURING_FULLSCREEN:
273   value = 'ignore', 'leave_fullscreen', 'smart'
274       -> call cfg_popup_during_fullscreen($value)
275
276 # client.background <hexcolor>
277 state COLOR_SINGLE:
278   color = word
279       -> call cfg_color_single($colorclass, $color)
280
281 # colorclass border background text indicator
282 state COLOR_BORDER:
283   border = word
284       -> COLOR_BACKGROUND
285
286 state COLOR_BACKGROUND:
287   background = word
288       -> COLOR_TEXT
289
290 state COLOR_TEXT:
291   text = word
292       -> COLOR_INDICATOR
293
294 state COLOR_INDICATOR:
295   indicator = word
296       -> call cfg_color($colorclass, $border, $background, $text, $indicator)
297   end
298       -> call cfg_color($colorclass, $border, $background, $text, NULL)
299
300 # <exec|exec_always> [--no-startup-id] command
301 state EXEC:
302   no_startup_id = '--no-startup-id'
303       ->
304   command = string
305       -> call cfg_exec($exectype, $no_startup_id, $command)
306
307 # font font
308 state FONT:
309   font = string
310       -> call cfg_font($font)
311
312 # bindsym/bindcode
313 state BINDING:
314   release = '--release'
315       ->
316   border = '--border'
317       ->
318   whole_window = '--whole-window'
319       ->
320   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl', 'Mode_switch', '$mod'
321       ->
322   '+'
323       ->
324   key = word
325       -> BINDCOMMAND
326
327 state BINDCOMMAND:
328   release = '--release'
329       ->
330   border = '--border'
331       ->
332   whole_window = '--whole-window'
333       ->
334   command = string
335       -> call cfg_binding($bindtype, $modifiers, $key, $release, $border, $whole_window, $command)
336
337 ################################################################################
338 # Mode configuration
339 ################################################################################
340
341 state MODENAME:
342   modename = word
343       -> call cfg_enter_mode($modename); MODEBRACE
344
345 state MODEBRACE:
346   end
347       ->
348   '{'
349       -> MODE
350
351 state MODE:
352   end ->
353   error ->
354   '#' -> MODE_IGNORE_LINE
355   'set' -> MODE_IGNORE_LINE
356   bindtype = 'bindsym', 'bindcode', 'bind'
357       -> MODE_BINDING
358   '}'
359       -> INITIAL
360
361 # We ignore comments and 'set' lines (variables).
362 state MODE_IGNORE_LINE:
363   line
364       -> MODE
365
366 state MODE_BINDING:
367   release = '--release'
368       ->
369   border = '--border'
370       ->
371   whole_window = '--whole-window'
372       ->
373   modifiers = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Shift', 'Control', 'Ctrl', 'Mode_switch', '$mod'
374       ->
375   '+'
376       ->
377   key = word
378       -> MODE_BINDCOMMAND
379
380 state MODE_BINDCOMMAND:
381   release = '--release'
382       ->
383   border = '--border'
384       ->
385   whole_window = '--whole-window'
386       ->
387   command = string
388       -> call cfg_mode_binding($bindtype, $modifiers, $key, $release, $border, $whole_window, $command); MODE
389
390 ################################################################################
391 # Bar configuration (i3bar)
392 ################################################################################
393
394 state BARBRACE:
395   end
396       ->
397   '{'
398       -> BAR
399
400 state BAR:
401   end ->
402   error ->
403   '#' -> BAR_IGNORE_LINE
404   'set' -> BAR_IGNORE_LINE
405   'i3bar_command'          -> BAR_BAR_COMMAND
406   'status_command'         -> BAR_STATUS_COMMAND
407   'socket_path'            -> BAR_SOCKET_PATH
408   'mode'                   -> BAR_MODE
409   'hidden_state'           -> BAR_HIDDEN_STATE
410   'id'                     -> BAR_ID
411   'modifier'               -> BAR_MODIFIER
412   'wheel_up_cmd'           -> BAR_WHEEL_UP_CMD
413   'wheel_down_cmd'         -> BAR_WHEEL_DOWN_CMD
414   'position'               -> BAR_POSITION
415   'output'                 -> BAR_OUTPUT
416   'tray_output'            -> BAR_TRAY_OUTPUT
417   'font'                   -> BAR_FONT
418   'separator_symbol'       -> BAR_SEPARATOR_SYMBOL
419   'binding_mode_indicator' -> BAR_BINDING_MODE_INDICATOR
420   'workspace_buttons'      -> BAR_WORKSPACE_BUTTONS
421   'strip_workspace_numbers' -> BAR_STRIP_WORKSPACE_NUMBERS
422   'verbose'                -> BAR_VERBOSE
423   'colors'                 -> BAR_COLORS_BRACE
424   '}'
425       -> call cfg_bar_finish(); INITIAL
426
427 # We ignore comments and 'set' lines (variables).
428 state BAR_IGNORE_LINE:
429   line
430       -> BAR
431
432 state BAR_BAR_COMMAND:
433   command = string
434       -> call cfg_bar_i3bar_command($command); BAR
435
436 state BAR_STATUS_COMMAND:
437   command = string
438       -> call cfg_bar_status_command($command); BAR
439
440 state BAR_SOCKET_PATH:
441   path = string
442       -> call cfg_bar_socket_path($path); BAR
443
444 state BAR_MODE:
445   mode = 'dock', 'hide', 'invisible'
446       -> call cfg_bar_mode($mode); BAR
447
448 state BAR_HIDDEN_STATE:
449   hidden_state = 'hide', 'show'
450       -> call cfg_bar_hidden_state($hidden_state); BAR
451
452 state BAR_ID:
453   bar_id = word
454       -> call cfg_bar_id($bar_id); BAR
455
456 state BAR_MODIFIER:
457   modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift'
458       -> call cfg_bar_modifier($modifier); BAR
459
460 state BAR_WHEEL_UP_CMD:
461   command = string
462       -> call cfg_bar_wheel_up_cmd($command); BAR
463
464 state BAR_WHEEL_DOWN_CMD:
465   command = string
466       -> call cfg_bar_wheel_down_cmd($command); BAR
467
468 state BAR_POSITION:
469   position = 'top', 'bottom'
470       -> call cfg_bar_position($position); BAR
471
472 state BAR_OUTPUT:
473   output = string
474       -> call cfg_bar_output($output); BAR
475
476 state BAR_TRAY_OUTPUT:
477   output = word
478       -> call cfg_bar_tray_output($output); BAR
479
480 state BAR_FONT:
481   font = string
482       -> call cfg_bar_font($font); BAR
483
484 state BAR_SEPARATOR_SYMBOL:
485   separator = string
486       -> call cfg_bar_separator_symbol($separator); BAR
487
488 state BAR_BINDING_MODE_INDICATOR:
489   value = word
490       -> call cfg_bar_binding_mode_indicator($value); BAR
491
492 state BAR_WORKSPACE_BUTTONS:
493   value = word
494       -> call cfg_bar_workspace_buttons($value); BAR
495
496 state BAR_STRIP_WORKSPACE_NUMBERS:
497   value = word
498       -> call cfg_bar_strip_workspace_numbers($value); BAR
499
500 state BAR_VERBOSE:
501   value = word
502       -> call cfg_bar_verbose($value); BAR
503
504 state BAR_COLORS_BRACE:
505   end
506       ->
507   '{'
508       -> BAR_COLORS
509
510 state BAR_COLORS:
511   end ->
512   '#' -> BAR_COLORS_IGNORE_LINE
513   'set' -> BAR_COLORS_IGNORE_LINE
514   colorclass = 'background', 'statusline', 'separator'
515       -> BAR_COLORS_SINGLE
516   colorclass = 'focused_workspace', 'active_workspace', 'inactive_workspace', 'urgent_workspace'
517       -> BAR_COLORS_BORDER
518   '}'
519       -> BAR
520
521 # We ignore comments and 'set' lines (variables).
522 state BAR_COLORS_IGNORE_LINE:
523   line
524       -> BAR_COLORS
525
526 state BAR_COLORS_SINGLE:
527   color = word
528       -> call cfg_bar_color_single($colorclass, $color); BAR_COLORS
529
530 state BAR_COLORS_BORDER:
531   border = word
532       -> BAR_COLORS_BACKGROUND
533
534 state BAR_COLORS_BACKGROUND:
535   background = word
536       -> BAR_COLORS_TEXT
537
538 state BAR_COLORS_TEXT:
539   end
540       -> call cfg_bar_color($colorclass, $border, $background, NULL); BAR_COLORS
541   text = word
542       -> call cfg_bar_color($colorclass, $border, $background, $text); BAR_COLORS