Calibre: Add icon and desktop file to Calibre

  • Done
  • quality assurance status badge
Details
6 participants
  • Brett Gilio
  • Tobias Geerinckx-Rice
  • Michael Rohleder
  • pkill9
  • Ricardo Wurmus
  • Tobias Geerinckx-Rice
Owner
unassigned
Submitted by
pkill9
Severity
normal

Debbugs page

pkill9 wrote 6 years ago
(name . guix-patches)(address . guix-patches@gnu.org)
E1gwA67-0001RN-Er@rmmprod05.runbox
This patch adds two phases to the package definition for Calibre that install an icon and install a desktop file.
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(-)

Toggle diff (40 lines)
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
Ricardo Wurmus wrote 6 years ago
(address . pkill9@runbox.com)(address . 34576@debbugs.gnu.org)
875ztfv59w.fsf@elephly.net
Hi pkill9,

Toggle quote (8 lines)
> + (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.

Toggle quote (19 lines)
> + (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 wrote 6 years ago
(name . Ricardo Wurmus)(address . rekado@elephly.net)(name . 34576)(address . 34576@debbugs.gnu.org)
E1gwJWF-0002re-HA@rmmprod05.runbox
Hi Ricardo,

Toggle quote (3 lines)
> 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:

Toggle quote (47 lines)
>
> 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 wrote 6 years ago
(address . pkill9@runbox.com)(name . Ricardo Wurmus)(address . rekado@elephly.net)(name . 34576)(address . 34576@debbugs.gnu.org)
87k1hvt5ox.fsf@posteo.net
pkill9@runbox.com writes:
Toggle quote (3 lines)
> 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
pkill9 wrote 6 years ago
(name . Ricardo Wurmus)(address . rekado@elephly.net)(name . 34576)(address . 34576@debbugs.gnu.org)
E1gwK5W-00056Z-Fk@rmmprod05.runbox
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.

Toggle quote (12 lines)
> 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 <rekado@elephly.net> wrote:

Toggle quote (47 lines)
>
> 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 <pkill9@runbox.com>
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(-)

Toggle diff (38 lines)
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
Tobias Geerinckx-Rice wrote 6 years ago
(address . pkill9@runbox.com)(name . Ricardo Wurmus)(address . rekado@elephly.net)(name . 34576)(address . 34576@debbugs.gnu.org)
87mumqwo0q.fsf@nckx
Pkill -9,

pkill9 wrote:
Toggle quote (6 lines)
> 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]'.

Zut alors! You had a typo.

Use Ricardo's snippet from the quoted message and make sure that
there's no trailing whitespace, particularly after "\ (as was
probably the case above). Emacs won't touch the indentation
inside the format string.

Thanks!

T G-R
Tobias Geerinckx-Rice wrote 6 years ago
(address . pkill9@runbox.com)(name . 34576)(address . 34576@debbugs.gnu.org)
87lg2awn8u.fsf@nckx
[I sent my previous message to this bug from the wrong address.
Oops! And sorry.]

Pkill -9,

pkill9 wrote:
Toggle quote (6 lines)
> - (add-after 'install 'install-font-liberation
> + (add-after 'install 'install-icon
> + (add-after 'install-icon 'install-desktop-file
> + (add-after 'install-desktop-file
> 'install-font-liberation

This is utterly correct and right and good, but…

In practice, one tends to just (ADD-AFTER 'INSTALL …) everywhere
instead of building up such nice (but brittle) orderings — unless
the phases actually depend on each other. It makes removing them
later slightly quicker.

(If you're thinking ‘Wait, doesn't that run them in the reverse
order?’ you're 1. paying attention and b. right. It hardly ever
matters.)

Kind regards,

T G-R
Michael Rohleder wrote 4 years ago
(address . pkill9@runbox.com)(address . 34576-done@debbugs.gnu.org)
87362y7hwj.fsf@rohleder.de
<pkill9@runbox.com> writes:
Toggle quote (2 lines)
> 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

--
Linux - Better for your uptime than Viagra
-----BEGIN PGP SIGNATURE-----

iQFFBAEBCAAvFiEEdV4t5dDVhcUueCgwfHr/vv7yyyUFAl91Sp0RHG1pa2VAcm9o
bGVkZXIuZGUACgkQfHr/vv7yyyUVpwf/Q+jCjs0JySHzchf9fPYHJYZc7vzpsPCm
7Sw3QJZA5l+a8SkhBX5x+Wyfm3k6KHAQ9/MVaCWpkaXpGu6OKt97XUs29w2Qa1n2
5Oy+EakcUeiyBM4np30/vshHwO6QnalFWQQqJlPU6igsy00hjTQboLiGMX2Ue3ND
xhQglSM7gDvOGmai+Q2RYIgLTOYCF890jhKH3aHaZpebnHob/NXPzbA0QhqvwhDv
N29cgcM+aiJbX0ncd+iTvqm7riMX1ieNtzz0EmXqRU0WDONHmRlZvV0/WRFfDMND
WiJ1BHgKmbEDqfXr+vV0xtO1zlIll9kK2pIkE7bIKSUrGWOhaGLtEw==
=P6PR
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 34576@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 34576
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help