launcher ".desktop" handling: preserve existing Exec= content

This commit is contained in:
Matthew Flatt 2013-11-02 20:30:49 -06:00
parent 89b89f91a3
commit b431d8fea1
2 changed files with 23 additions and 7 deletions

View File

@ -117,11 +117,15 @@ the following additional associations apply to launchers:
@item{@racket['desktop] (Unix) --- a string containing the content of
a @filepath{.desktop} file for the launcher, where @tt{Exec}
and @tt{Icon} items should be omitted, because they will be
added automatically. The file is written to the directory
produced by @racket[(find-apps-dir)] or
@racket[(find-user-apps-dir)]. A @racket['desktop] value is
used only when @racket['install-mode] is also specified.}
and @tt{Icon} entries are added automatically. If an @tt{Exec}
entry exists in the string, and if its value starts with a
non-empty sequence of alpha-numeric ASCII characters followed
by a space, then the space and remainder of the value is
appended to the automatically generated value.
The @filepath{.desktop} file is written to the directory produced by
@racket[(find-apps-dir)] or @racket[(find-user-apps-dir)]. A
@racket['desktop] value is used only when
@racket['install-mode] is also specified.}
@item{@racket['png] (Unix) : An icon file path (suffix
@filepath{.png}) to be referenced by a @filepath{.desktop}

View File

@ -539,8 +539,20 @@
file
#:exists 'truncate
(lambda (o)
(displayln (regexp-replace #rx"\n+$" (cdr m) "") o)
(fprintf o "Exec=~a\n" (adjust-path dest))
(define content (cdr m))
(displayln (regexp-replace #rx"\n+$"
(regexp-replace "(?m:^Exec=.*)\n*"
content
"")
"")
o)
(fprintf o "Exec=~a~a\n"
(adjust-path dest)
;; Keep rest of existing line, if any:
(let ([m (regexp-match "(?m:^Exec=[a-zA-Z0-9]+( .*))" content)])
(if m
(cadr m)
"")))
(let ([m (or (assq 'png aux)
(assq 'ico aux))])
(when m