3 Desktop module for Augeas (.desktop files)
5 Author: Raphael Pinson <raphink@gmail.com>
8 This lens is made to provide a lens for .desktop files for augeas
10 Reference: Freedesktop.org
11 http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
14 This file is licenced under the LGPL v2+, like the rest of Augeas.
19 (* We don't load this lens by default
20 Since a lot of desktop files contain unicode characters
21 which we can't parse *)
24 (* Comments can be only of # type *)
25 let comment = IniFile.comment "#" "#"
29 * These represents sections of a desktop file
30 * Example : [DesktopEntry]
33 let title = IniFile.title IniFile.record_re
35 let sep = IniFile.sep "=" "="
37 let setting = /[A-Za-z0-9_.-]+([][@A-Za-z0-9_.-]+)?/
39 (* Variable: sto_to_comment
40 Store until comment *)
41 let sto_to_comment = Sep.opt_space . store /[^# \t\r\n][^#\r\n]*[^# \t\r\n]|[^# \t\r\n]/
43 (* Entries can have comments at their end and so they are modified to represent as such *)
44 let entry = [ key setting . sep . sto_to_comment? . (comment|IniFile.eol) ] | comment
46 let record = IniFile.record title entry
48 let lns = IniFile.lns record comment
50 let filter = ( incl "/usr/share/applications/*.desktop"
51 . incl "/usr/share/applications/screensavers/*.desktop" )
53 let xfm = transform lns filter