3 Parses /etc/X11/xorg.conf
5 Authors: Raphael Pinson <raphink@gmail.com>
6 Matthew Booth <mbooth@redhat.com>
9 This lens tries to keep as close as possible to `man xorg.conf` where
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.
16 This file is licensed under the LGPLv2+, like the rest of Augeas.
19 Sample usage of this lens in augtool
21 * Get the identifier of the devices with a "Clone" option:
22 > match "/files/etc/X11/xorg.conf/Device[Option = 'Clone']/Identifier"
24 About: Configuration files
25 This lens applies to /etc/X11/xorg.conf. See <filter>.
31 (************************************************************************
32 * Group: USEFUL PRIMITIVES
33 *************************************************************************)
35 (* Group: Generic primitives *)
41 * Match everything from here to eol, cropping whitespace at both ends
43 let to_eol = /[^ \t\n](.*[^ \t\n])?/
45 (* Variable: indent *)
46 let indent = Util.indent
48 (* Variable: comment *)
49 let comment = Util.comment
52 let empty = Util.empty
55 (* Group: Separators *)
57 (* Variable: sep_spc *)
58 let sep_spc = Util.del_ws_spc
60 (* Variable: sep_dquote *)
61 let sep_dquote = Util.del_str "\""
64 (* Group: Fields and values *)
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
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)/
72 (* Variable: generic_entry_re *)
73 let generic_entry_re = /[^# \t\n\/]+/ - entries_re
75 (* Variable: quoted_non_empty_string_val *)
76 let quoted_non_empty_string_val = del "\"" "\"" . store /[^"\n]+/
80 (* Variable: quoted_string_val *)
81 let quoted_string_val = del "\"" "\"" . store /[^"\n]*/ . del "\"" "\""
88 (************************************************************************
89 * Group: ENTRIES AND OPTIONS
90 *************************************************************************)
94 * This matches an entry which takes a single integer for an argument
96 let entry_int (canon:string) (re:regexp) =
97 [ indent . del re canon . label canon . sep_spc . store int . eol ]
100 * This matches an entry which takes 3 integers as arguments representing red,
101 * green and blue components
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 ]
111 * This matches an entry which takes 2 integers as arguments representing X and
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 ]
121 * This matches an entry which takes a single quoted string
123 let entry_str (canon:string) (re:regexp) =
124 [ indent . del re canon . label canon
125 . sep_spc . quoted_non_empty_string_val . eol ]
127 (* View: entry_generic
128 * An entry without a specific handler. Store everything after the keyword,
129 * cropping whitespace at both ends.
131 let entry_generic = [ indent . key generic_entry_re
132 . sep_spc . store to_eol . eol ]
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 ]*
141 * The Screen entry of ServerLayout
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 ]? )?
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 ]*
158 let driver = entry_str "Driver" /[dD]river/
160 (* View: identifier *)
161 let identifier = entry_str "Identifier" /[iI]dentifier/
164 let videoram = entry_int "VideoRam" /[vV]ideo[rR]am/
166 (* View: default_depth *)
167 let default_depth = entry_int "DefaultDepth" /[dD]efault[dD]epth/
170 let device = entry_str "Device" /[dD]evice/
172 (************************************************************************
173 * Group: DISPLAY SUBSECTION
174 *************************************************************************)
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 ]+
183 (*************************************************************************
184 * View: display_entry
185 * Known values for entries in the Display subsection
190 * > Weight red-weight green-weight blue-weight
191 * > Virtual xdim ydim
193 * > Modes "mode-name" ...
194 * > Visual "visual-name"
195 * > Black red green blue
196 * > White red green blue
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/ |
206 entry_str "Visual" /[vV]isual/ |
207 entry_rgb "Black" /[bB]lack/ |
208 entry_rgb "White" /[wW]hite/ |
209 entry_str "Options" /[oO]ptions/ |
214 let display = [ indent . del "SubSection" "SubSection" . sep_spc
215 . sep_dquote . key "Display" . sep_dquote
218 . indent . del "EndSubSection" "EndSubSection" . eol ]
220 (************************************************************************
221 * Group: EXTMOD SUBSECTION
222 *************************************************************************)
224 let extmod_entry = entry_str "Option" /[oO]ption/ |
228 let extmod = [ indent . del "SubSection" "SubSection" . sep_spc
229 . sep_dquote . key "extmod" . sep_dquote
232 . indent . del "EndSubSection" "EndSubSection" . eol ]
234 (************************************************************************
236 *************************************************************************)
239 (************************************************************************
240 * Variable: section_re
241 * Known values for Section names
244 * > The section names are:
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)/
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.
271 * > Keyboard Keyboard configuration
272 * > Pointer Pointer/mouse configuration
273 *************************************************************************)
274 let section_re_obsolete = /(Keyboard|Pointer)/
276 (* View: section_entry *)
277 let section_entry = option |
290 (************************************************************************
292 * A section in xorg.conf
295 * > Section "SectionName"
299 *************************************************************************)
300 let section = [ indent . del "Section" "Section"
301 . sep_spc . sep_dquote
302 . key (section_re|section_re_obsolete) . sep_dquote
305 . indent . del "EndSection" "EndSection" . eol ]
311 let lns = ( empty | comment | section )*
314 (* Variable: filter *)
315 let filter = incl "/etc/X11/xorg.conf"
316 . incl "/etc/X11/xorg.conf.d/*.conf"
319 let xfm = transform lns filter