|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Desktop
|
|
Packit Service |
a2ae7a |
Desktop module for Augeas (.desktop files)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Raphael Pinson <raphink@gmail.com>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Lens Usage
|
|
Packit Service |
a2ae7a |
This lens is made to provide a lens for .desktop files for augeas
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Reference: Freedesktop.org
|
|
Packit Service |
a2ae7a |
http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: License
|
|
Packit Service |
a2ae7a |
This file is licenced under the LGPL v2+, like the rest of Augeas.
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module Desktop =
|
|
Packit Service |
a2ae7a |
(* We don't load this lens by default
|
|
Packit Service |
a2ae7a |
Since a lot of desktop files contain unicode characters
|
|
Packit Service |
a2ae7a |
which we can't parse *)
|
|
Packit Service |
a2ae7a |
(* autoload xfm *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Comments can be only of # type *)
|
|
Packit Service |
a2ae7a |
let comment = IniFile.comment "#" "#"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* TITLE
|
|
Packit Service |
a2ae7a |
* These represents sections of a desktop file
|
|
Packit Service |
a2ae7a |
* Example : [DesktopEntry]
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let title = IniFile.title IniFile.record_re
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let sep = IniFile.sep "=" "="
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let setting = /[A-Za-z0-9_.-]+([][@A-Za-z0-9_.-]+)?/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: sto_to_comment
|
|
Packit Service |
a2ae7a |
Store until comment *)
|
|
Packit Service |
a2ae7a |
let sto_to_comment = Sep.opt_space . store /[^# \t\r\n][^#\r\n]*[^# \t\r\n]|[^# \t\r\n]/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Entries can have comments at their end and so they are modified to represent as such *)
|
|
Packit Service |
a2ae7a |
let entry = [ key setting . sep . sto_to_comment? . (comment|IniFile.eol) ] | comment
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let record = IniFile.record title entry
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let lns = IniFile.lns record comment
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let filter = ( incl "/usr/share/applications/*.desktop"
|
|
Packit Service |
a2ae7a |
. incl "/usr/share/applications/screensavers/*.desktop" )
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns filter
|