Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / xorg.aug
1 (*
2 Module: Xorg
3  Parses /etc/X11/xorg.conf
4
5 Authors: Raphael Pinson <raphink@gmail.com>
6          Matthew Booth <mbooth@redhat.com>
7
8 About: Reference
9  This lens tries to keep as close as possible to `man xorg.conf` where
10  possible.
11
12 The definitions from `man xorg.conf` are put as commentaries for reference
13 throughout the file. More information can be found in the manual.
14
15 About: License
16   This file is licensed under the LGPLv2+, like the rest of Augeas.
17
18 About: Lens Usage
19   Sample usage of this lens in augtool
20
21     * Get the identifier of the devices with a "Clone" option:
22       > match "/files/etc/X11/xorg.conf/Device[Option = 'Clone']/Identifier"
23
24 About: Configuration files
25   This lens applies to /etc/X11/xorg.conf. See <filter>.
26 *)
27
28 module Xorg =
29   autoload xfm
30
31 (************************************************************************
32  * Group:                 USEFUL PRIMITIVES
33  *************************************************************************)
34
35 (* Group: Generic primitives *)
36
37 (* Variable: eol *)
38 let eol     = Util.eol
39
40 (* Variable: to_eol
41  * Match everything from here to eol, cropping whitespace at both ends
42  *)
43 let to_eol  = /[^ \t\n](.*[^ \t\n])?/
44
45 (* Variable: indent *)
46 let indent  = Util.indent
47
48 (* Variable: comment *)
49 let comment = Util.comment
50
51 (* Variable: empty *)
52 let empty   = Util.empty
53
54
55 (* Group: Separators *)
56
57 (* Variable: sep_spc *)
58 let sep_spc = Util.del_ws_spc
59
60 (* Variable: sep_dquote *)
61 let sep_dquote  = Util.del_str "\""
62
63
64 (* Group: Fields and values *)
65
66 (* Variable: entries_re
67  * This is a list of all patterns which have specific handlers, and should
68  * therefore not be matched by the generic handler
69  *)
70 let entries_re  = /([oO]ption|[sS]creen|[iI]nput[dD]evice|[dD]river|[sS]ub[sS]ection|[dD]isplay|[iI]dentifier|[vV]ideo[rR]am|[dD]efault[dD]epth|[dD]evice)/
71
72 (* Variable: generic_entry_re *)
73 let generic_entry_re = /[^# \t\n\/]+/ - entries_re
74
75 (* Variable: quoted_non_empty_string_val *)
76 let quoted_non_empty_string_val = del "\"" "\"" . store /[^"\n]+/
77                                   . del "\"" "\""
78                                               (* " relax, emacs *)
79
80 (* Variable: quoted_string_val *)
81 let quoted_string_val = del "\"" "\"" . store /[^"\n]*/ . del "\"" "\""
82                                               (* " relax, emacs *)
83
84 (* Variable: int *)
85 let int = /[0-9]+/
86
87
88 (************************************************************************
89  * Group:                          ENTRIES AND OPTIONS
90  *************************************************************************)
91
92
93 (* View: entry_int
94  * This matches an entry which takes a single integer for an argument
95  *)
96 let entry_int (canon:string) (re:regexp) =
97         [ indent . del re canon . label canon . sep_spc . store int . eol ]
98
99 (* View: entry_rgb
100  * This matches an entry which takes 3 integers as arguments representing red,
101  * green and blue components
102  *)
103 let entry_rgb (canon:string) (re:regexp) =
104         [ indent . del re canon . label canon
105           . [ label "red"   . sep_spc . store int ]
106           . [ label "green" . sep_spc . store int ]
107           . [ label "blue"  . sep_spc . store int ]
108           . eol ]
109
110 (* View: entry_xy
111  * This matches an entry which takes 2 integers as arguments representing X and
112  * Y coordinates
113  *)
114 let entry_xy (canon:string) (re:regexp) =
115         [ indent . del re canon . label canon
116           . [ label "x" . sep_spc . store int ]
117           . [ label "y" . sep_spc . store int ]
118           . eol ]
119
120 (* View: entry_str
121  * This matches an entry which takes a single quoted string
122  *)
123 let entry_str (canon:string) (re:regexp) =
124         [ indent . del re canon . label canon
125           . sep_spc . quoted_non_empty_string_val . eol ]
126
127 (* View: entry_generic
128  * An entry without a specific handler. Store everything after the keyword,
129  * cropping whitespace at both ends.
130  *)
131 let entry_generic  = [ indent . key generic_entry_re
132                        . sep_spc . store to_eol . eol ]
133
134 (* View: option *)
135 let option = [ indent . del /[oO]ption/ "Option" . label "Option" . sep_spc
136                . quoted_non_empty_string_val
137                . [ label "value" . sep_spc . quoted_string_val ]*
138                . eol ]
139
140 (* View: screen
141  * The Screen entry of ServerLayout
142  *)
143 let screen = [ indent . del /[sS]creen/ "Screen" . label "Screen"
144                . [ sep_spc . label "num" . store int ]?
145                . ( sep_spc . quoted_non_empty_string_val
146                . [ sep_spc . label "position" . store to_eol ]? )?
147                . eol ]
148
149 (* View: input_device *)
150 let input_device = [ indent . del /[iI]nput[dD]evice/ "InputDevice"
151                      . label "InputDevice" . sep_spc
152                      . quoted_non_empty_string_val
153                      . [ label "option" . sep_spc
154                          . quoted_non_empty_string_val ]*
155                      . eol ]
156
157 (* View: driver *)
158 let driver = entry_str "Driver" /[dD]river/
159
160 (* View: identifier *)
161 let identifier = entry_str "Identifier" /[iI]dentifier/
162
163 (* View: videoram *)
164 let videoram = entry_int "VideoRam" /[vV]ideo[rR]am/
165
166 (* View: default_depth *)
167 let default_depth = entry_int "DefaultDepth" /[dD]efault[dD]epth/
168
169 (* View: device *)
170 let device = entry_str "Device" /[dD]evice/
171
172 (************************************************************************
173  * Group:                          DISPLAY SUBSECTION
174  *************************************************************************)
175
176
177 (* View: display_modes *)
178 let display_modes = [ indent . del /[mM]odes/ "Modes" . label "Modes"
179                       . [ label "mode" . sep_spc
180                           . quoted_non_empty_string_val ]+
181                       . eol ]
182
183 (*************************************************************************
184  * View: display_entry
185  *   Known values for entries in the Display subsection
186  *
187  *   Definition:
188  *     > Depth    depth
189  *     > FbBpp    bpp
190  *     > Weight   red-weight green-weight blue-weight
191  *     > Virtual  xdim ydim
192  *     > ViewPort x0 y0
193  *     > Modes    "mode-name" ...
194  *     > Visual   "visual-name"
195  *     > Black    red green blue
196  *     > White    red green blue
197  *     > Options
198  *)
199
200 let display_entry = entry_int "Depth"    /[dD]epth/ |
201                     entry_int "FbBpp"    /[fF]b[bB]pp/ |
202                     entry_rgb "Weight"   /[wW]eight/ |
203                     entry_xy  "Virtual"  /[vV]irtual/ |
204                     entry_xy  "ViewPort" /[vV]iew[pP]ort/ |
205                     display_modes |
206                     entry_str "Visual"   /[vV]isual/ |
207                     entry_rgb "Black"    /[bB]lack/ |
208                     entry_rgb "White"    /[wW]hite/ |
209                     entry_str "Options"  /[oO]ptions/ |
210                     empty |
211                     comment
212
213 (* View: display *)
214 let display = [ indent . del "SubSection" "SubSection" . sep_spc
215                        . sep_dquote . key "Display" . sep_dquote
216                        . eol
217                        . display_entry*
218                        . indent . del "EndSubSection" "EndSubSection" . eol ]
219
220 (************************************************************************
221  * Group:                          EXTMOD SUBSECTION
222  *************************************************************************)
223
224 let extmod_entry =  entry_str "Option"  /[oO]ption/ |
225                     empty |
226                     comment
227
228 let extmod = [ indent . del "SubSection" "SubSection" . sep_spc
229                        . sep_dquote . key "extmod" . sep_dquote
230                        . eol
231                        . extmod_entry*
232                        . indent . del "EndSubSection" "EndSubSection" . eol ]
233
234 (************************************************************************
235  * Group:                       SECTIONS
236  *************************************************************************)
237
238
239 (************************************************************************
240  * Variable: section_re
241  *   Known values for Section names
242  *
243  *   Definition:
244  *     >   The section names are:
245  *     >
246  *     >   Files          File pathnames
247  *     >   ServerFlags    Server flags
248  *     >   Module         Dynamic module loading
249  *     >   Extensions     Extension Enabling
250  *     >   InputDevice    Input device description
251  *     >   InputClass     Input Class description
252  *     >   Device         Graphics device description
253  *     >   VideoAdaptor   Xv video adaptor description
254  *     >   Monitor        Monitor description
255  *     >   Modes          Video modes descriptions
256  *     >   Screen         Screen configuration
257  *     >   ServerLayout   Overall layout
258  *     >   DRI            DRI-specific configuration
259  *     >   Vendor         Vendor-specific configuration
260  *************************************************************************)
261 let section_re = /(Extensions|Files|ServerFlags|Module|InputDevice|InputClass|Device|VideoAdaptor|Monitor|Modes|Screen|ServerLayout|DRI|Vendor)/
262
263
264 (************************************************************************
265  * Variable: secton_re_obsolete
266  *   The  following obsolete section names are still recognised for
267  *   compatibility purposes.  In new config files, the InputDevice
268  *   section should be used instead.
269  *
270  *   Definition:
271  *     >  Keyboard       Keyboard configuration
272  *     >  Pointer        Pointer/mouse configuration
273  *************************************************************************)
274 let section_re_obsolete = /(Keyboard|Pointer)/
275
276 (* View: section_entry *)
277 let section_entry = option |
278                     screen |
279                     display |
280                     extmod |
281                     input_device |
282                     driver |
283                     identifier |
284                     videoram |
285                     default_depth |
286                     device |
287                     entry_generic |
288                     empty | comment
289
290 (************************************************************************
291  * View: section
292  *   A section in xorg.conf
293  *
294  *   Definition:
295  *     > Section  "SectionName"
296  *     >    SectionEntry
297  *     >    ...
298  *     > EndSection
299  *************************************************************************)
300 let section = [ indent . del "Section" "Section"
301                        . sep_spc . sep_dquote
302                        . key (section_re|section_re_obsolete) . sep_dquote
303                        . eol
304                 .  section_entry*
305                 . indent . del "EndSection" "EndSection" . eol ]
306
307 (*
308  * View: lns
309  *   The xorg.conf lens
310  *)
311 let lns = ( empty | comment | section )*
312
313
314 (* Variable: filter *)
315 let filter = incl "/etc/X11/xorg.conf"
316            . incl "/etc/X11/xorg.conf.d/*.conf"
317            . Util.stdexcl
318
319 let xfm = transform lns filter