Subject: [bug#34576] Calibre: Add icon and desktop file to Calibre

From: <[email-masked]>
Date: Wed, 20 Feb 2019 05:06:30 +0000 (GMT)

I've attached a patch with the 'let' removed from the icon install phase, but I haven't changed the indentation of the desktop file because when I did that it added a blank line at the beginning of the desktop file and created a large indentation before '[Desktop Entry]'. I moved 'out' to be next to the last line of the desktop file output.

> Secondly, the indentation is odd.  I’d write it like this:
> 
>      (format #t "\
> [Desktop Entry]~@
> Name=…
> Comment=…
> …
> Type=Application~%" out)
> 
> 
> --

I used the xonotic package definition as a reference for thi part, and emacs' `indent-region` indents it like this. I don't know how it should look. I've attached a patch for now.

On Tue, 19 Feb 2019 22:26:35 +0100, Ricardo Wurmus <[email-masked]> wrote:

> 
> Hi pkill9,
> 
> > +         (add-after 'install 'install-icon
> > +           (lambda* (#:key outputs #:allow-other-keys)
> > +             (let* ((out (assoc-ref outputs "out")))
> > +               (install-file "imgsrc/calibre.svg"
> > +                             (string-append out
> > +                                            "/share/icons/hicolor/scalable/apps")))
> > +             #t))
> 
> You can do without “let*” here.
> 
> > +         (add-after 'install-icon 'install-desktop-file
> > +           (lambda* (#:key outputs #:allow-other-keys)
> > +             (let ((out (assoc-ref outputs "out")))
> > +               (mkdir-p (string-append out "/share/applications"))
> > +               (with-output-to-file
> > +                   (string-append out "/share/applications/calibre.desktop")
> > +                 (lambda _
> > +                   (format #t
> > +                           "[Desktop Entry]~@
> > +                Name=Calibre~@
> > +                Comment=E-book organiser and reader~@
> > +                Exec=~a/bin/calibre~@
> > +                TryExec=~@*~a/bin/calibre~@
> > +                Icon=calibre~@
> > +                Categories=Office~@
> > +                Type=Application~%"
> > +                           out)))
> > +               #t)))
> 
> Does upstream not provide a desktop file?  I’d rather see this submitted
> to upstream.  Have you contacted the developers about this?
> 
> Secondly, the indentation is odd.  I’d write it like this:
> 
>      (format #t "\
> [Desktop Entry]~@
> Name=…
> Comment=…
> …
> Type=Application~%" out)
> 
> 
> --
> Ricardo

From 14b7aacec811dd8fbbc7d87846dc4722b13522c9 Mon Sep 17 00:00:00 2001
From: Pkill -9 <[email-masked]>
Date: Wed, 20 Feb 2019 05:01:13 +0000
Subject: [PATCH] gnu: calibre: Add desktop file and icon.

* gnu/packages/ebook.scm (calibre): Add desktop file and icon.
---
 gnu/packages/ebook.scm | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/ebook.scm b/gnu/packages/ebook.scm
index 99e49bc17..a34664863 100644
--- a/gnu/packages/ebook.scm
+++ b/gnu/packages/ebook.scm
@@ -185,7 +185,30 @@
               (setenv "PODOFO_INC_DIR" (string-append podofo "/include/podofo"))
               (setenv "PODOFO_LIB_DIR" (string-append podofo "/lib"))
               #t)))
-         (add-after 'install 'install-font-liberation
+         (add-after 'install 'install-icon
+           (lambda* (#:key outputs #:allow-other-keys)
+             (install-file "imgsrc/calibre.svg"
+                             (string-append (assoc-ref outputs "out")
+                                            "/share/icons/hicolor/scalable/apps"))
+             #t))
+         (add-after 'install-icon 'install-desktop-file
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (mkdir-p (string-append out "/share/applications"))
+               (with-output-to-file
+                   (string-append out "/share/applications/calibre.desktop")
+                 (lambda _
+                   (format #t
+                           "[Desktop Entry]~@
+                Name=Calibre~@
+                Comment=E-book organiser and reader~@
+                Exec=~a/bin/calibre~@
+                TryExec=~@*~a/bin/calibre~@
+                Icon=calibre~@
+                Categories=Office~@
+                Type=Application~%" out))))
+             #t))
+         (add-after 'install-desktop-file 'install-font-liberation
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (for-each (lambda (file)
                          (install-file file (string-append
-- 
2.20.1