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

Message ID E1gwA67-0001RN-Er@rmmprod05.runbox
State Accepted
Headers show
Series [bug#34576] Calibre: Add icon and desktop file to Calibre | expand

Checks

Context Check Description
cbaines/applying patch fail Apply failed

Commit Message

pkill9 Feb. 19, 2019, 6:26 p.m. UTC
This patch adds two phases to the package definition for Calibre that install an icon and install a desktop file.

Comments

Ricardo Wurmus Feb. 19, 2019, 9:26 p.m. UTC | #1
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
pkill9 Feb. 20, 2019, 4:30 a.m. UTC | #2
Hi Ricardo,

> Does upstream not provide a desktop file?  I’d rather see this submitted
> to upstream.  Have you contacted the developers about this?

It looks like it does provide a desktop file looking at this pull request: https://github.com/kovidgoyal/calibre/pull/739, which modifies this file (link to line showing desktop file): https://github.com/kovidgoyal/calibre/blob/master/src/calibre/linux.py#L1031

It's created using a Python script though, perhaps it doesn't get run during building?

I thought the developer wouldn't add it upstream because I remember investigating a long time ago and finding the developer writing somewhere that they wouldn't add a desktop file upstream and that it was the linux packager's job to do that, maybe I am mis-remembering or it was in some other context.

On Tue, 19 Feb 2019 22:26:35 +0100, Ricardo Wurmus <rekado@elephly.net> 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
Brett Gilio Feb. 20, 2019, 5 a.m. UTC | #3
pkill9@runbox.com writes:
> I thought the developer wouldn't add it upstream because I remember investigating a long time ago and finding the developer writing somewhere that they wouldn't add a desktop file upstream and that it was the linux packager's job to do that, maybe I am mis-remembering or it was in some other context.


While we are on that topic, the Calibre maintainer can be (said
lovingly) stubborn about some things. On a related topic, Calibre (to my
knowledge) is going to remain on python2 forever at his choice because
of a political disagreement with python3.

Correctness aside, that might have some impact on our upcoming "Great
Python 2 Purge".

Brett Gilio
Michael Rohleder Oct. 1, 2020, 3:18 a.m. UTC | #4
<pkill9@runbox.com> writes:
> This patch adds two phases to the package definition for Calibre that install an icon and install a desktop file.

I believe, this is done with 6e1ab5fadbc8fbe5d8d71864c68dd52ddbc732c9

Patch

From 894a471083105a182d548c2b80effb0eb70c8fa6 Mon Sep 17 00:00:00 2001
From: Pkill -9 <pkill9@runbox.com>
Date: Tue, 19 Feb 2019 18:23:37 +0000
Subject: [PATCH] gnu: calibre: Add icon and desktop file.

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

diff --git a/gnu/packages/ebook.scm b/gnu/packages/ebook.scm
index 99e49bc17..ae899e04b 100644
--- a/gnu/packages/ebook.scm
+++ b/gnu/packages/ebook.scm
@@ -185,7 +185,32 @@ 
               (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)
+             (let* ((out (assoc-ref outputs "out")))
+               (install-file "imgsrc/calibre.svg"
+                             (string-append 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