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_string_val *)
76 let quoted_string_val = del "\"" "\"" . store /[^"\n]+/ . del "\"" "\""
83 (************************************************************************
84 * Group: ENTRIES AND OPTIONS
85 *************************************************************************)
89 * This matches an entry which takes a single integer for an argument
91 let entry_int (canon:string) (re:regexp) =
92 [ indent . del re canon . label canon . sep_spc . store int . eol ]
95 * This matches an entry which takes 3 integers as arguments representing red,
96 * green and blue components
98 let entry_rgb (canon:string) (re:regexp) =
99 [ indent . del re canon . label canon
100 . [ label "red" . sep_spc . store int ]
101 . [ label "green" . sep_spc . store int ]
102 . [ label "blue" . sep_spc . store int ]
106 * This matches an entry which takes 2 integers as arguments representing X and
109 let entry_xy (canon:string) (re:regexp) =
110 [ indent . del re canon . label canon
111 . [ label "x" . sep_spc . store int ]
112 . [ label "y" . sep_spc . store int ]
116 * This matches an entry which takes a single quoted string
118 let entry_str (canon:string) (re:regexp) =
119 [ indent . del re canon . label canon
120 . sep_spc . quoted_string_val . eol ]
122 (* View: entry_generic
123 * An entry without a specific handler. Store everything after the keyword,
124 * cropping whitespace at both ends.
126 let entry_generic = [ indent . key generic_entry_re
127 . sep_spc . store to_eol . eol ]
130 let option = [ indent . del /[oO]ption/ "Option" . label "Option" . sep_spc
132 . [ label "value" . sep_spc . quoted_string_val ]*
136 * The Screen entry of ServerLayout
138 let screen = [ indent . del /[sS]creen/ "Screen" . label "Screen"
139 . [ sep_spc . label "num" . store int ]?
140 . ( sep_spc . quoted_string_val
141 . [ sep_spc . label "position" . store to_eol ]? )?
144 (* View: input_device *)
145 let input_device = [ indent . del /[iI]nput[dD]evice/ "InputDevice"
146 . label "InputDevice" . sep_spc . quoted_string_val
147 . [ label "option" . sep_spc . quoted_string_val ]*
151 let driver = entry_str "Driver" /[dD]river/
153 (* View: identifier *)
154 let identifier = entry_str "Identifier" /[iI]dentifier/
157 let videoram = entry_int "VideoRam" /[vV]ideo[rR]am/
159 (* View: default_depth *)
160 let default_depth = entry_int "DefaultDepth" /[dD]efault[dD]epth/
163 let device = entry_str "Device" /[dD]evice/
165 (************************************************************************
166 * Group: DISPLAY SUBSECTION
167 *************************************************************************)
170 (* View: display_modes *)
171 let display_modes = [ indent . del /[mM]odes/ "Modes" . label "Modes"
172 . [ label "mode" . sep_spc . quoted_string_val ]+
175 (*************************************************************************
176 * View: display_entry
177 * Known values for entries in the Display subsection
182 * > Weight red-weight green-weight blue-weight
183 * > Virtual xdim ydim
185 * > Modes "mode-name" ...
186 * > Visual "visual-name"
187 * > Black red green blue
188 * > White red green blue
192 let display_entry = entry_int "Depth" /[dD]epth/ |
193 entry_int "FbBpp" /[fF]b[bB]pp/ |
194 entry_rgb "Weight" /[wW]eight/ |
195 entry_xy "Virtual" /[vV]irtual/ |
196 entry_xy "ViewPort" /[vV]iew[pP]ort/ |
198 entry_str "Visual" /[vV]isual/ |
199 entry_rgb "Black" /[bB]lack/ |
200 entry_rgb "White" /[wW]hite/ |
201 entry_str "Options" /[oO]ptions/ |
206 let display = [ indent . del "SubSection" "SubSection" . sep_spc
207 . sep_dquote . key "Display" . sep_dquote
210 . indent . del "EndSubSection" "EndSubSection" . eol ]
212 (************************************************************************
213 * Group: EXTMOD SUBSECTION
214 *************************************************************************)
216 let extmod_entry = entry_str "Option" /[oO]ption/ |
220 let extmod = [ indent . del "SubSection" "SubSection" . sep_spc
221 . sep_dquote . key "extmod" . sep_dquote
224 . indent . del "EndSubSection" "EndSubSection" . eol ]
226 (************************************************************************
228 *************************************************************************)
231 (************************************************************************
232 * Variable: section_re
233 * Known values for Section names
236 * > The section names are:
238 * > Files File pathnames
239 * > ServerFlags Server flags
240 * > Module Dynamic module loading
241 * > Extensions Extension Enabling
242 * > InputDevice Input device description
243 * > InputClass Input Class description
244 * > Device Graphics device description
245 * > VideoAdaptor Xv video adaptor description
246 * > Monitor Monitor description
247 * > Modes Video modes descriptions
248 * > Screen Screen configuration
249 * > ServerLayout Overall layout
250 * > DRI DRI-specific configuration
251 * > Vendor Vendor-specific configuration
252 *************************************************************************)
253 let section_re = /(Extensions|Files|ServerFlags|Module|InputDevice|InputClass|Device|VideoAdaptor|Monitor|Modes|Screen|ServerLayout|DRI|Vendor)/
256 (************************************************************************
257 * Variable: secton_re_obsolete
258 * The following obsolete section names are still recognised for
259 * compatibility purposes. In new config files, the InputDevice
260 * section should be used instead.
263 * > Keyboard Keyboard configuration
264 * > Pointer Pointer/mouse configuration
265 *************************************************************************)
266 let section_re_obsolete = /(Keyboard|Pointer)/
268 (* View: section_entry *)
269 let section_entry = option |
282 (************************************************************************
284 * A section in xorg.conf
287 * > Section "SectionName"
291 *************************************************************************)
292 let section = [ indent . del "Section" "Section"
293 . sep_spc . sep_dquote
294 . key (section_re|section_re_obsolete) . sep_dquote
297 . indent . del "EndSection" "EndSection" . eol ]
303 let lns = ( empty | comment | section )*
306 (* Variable: filter *)
307 let filter = incl "/etc/X11/xorg.conf"
308 . incl "/etc/X11/xorg.conf.d/*.conf"
311 let xfm = transform lns filter