Calibre and PDFs

In Calibre, when I try to view a PDF, instead of launching a viewer Calibre just attempts to re-import the file and I end up with two copies of the file in my library. Calibre has been doing this since I started using NixOS six months ago. Largely, I’ve just worked around it by going directly to the file on my filesystem.

Today, I finally fixed it on a whim. First, I launched calibre from the command line. When I tried to open a PDF file, I saw an error message about “evince” not being found. Interestingly, evince is in one of the paths that it listed, but whatever. The calibre derivation does not seem to accept any relevant parameters, so I opted to add evince to the buildInputs directive in calibre. And, since I learned how to use overlays a few months ago, I just added this to my overlays file:

  calibre = super.calibre.overrideAttrs (attrs: {
    buildInputs = attrs.buildInputs ++ [ super.evince ];
  });

This is all it takes to make calibre correctly launch evince with PDF files.

Here’s a link to the relevant line in my configuration repo: https://github.com/savannidgerinel/nix-shell/blob/ceea3b0098f2d92692d906fb088676ba164799e5/overlays.nix#L14

2 Likes

Hello,

I might be wrong, but I believe that if Calibre does require Evince to work properly, then, pull-requesting this fix could be a good idea :).

1 Like

I might be wrong, but I believe that if Calibre does require Evince to
work properly, then, pull-requesting this fix could be a good idea :).

Alternatively, patch calibre to call xdg-open instead as that should work with the default viewer on other platforms (okular on KDE as an example).

So… I looked again… and Calibre is actually launching Okular. Keep in mind, before I added evince to the override, Calibre would not launch anything for PDFs, just import the PDF again and create duplicate entries. So I’m kinda mystified. I’m installing from the 19.09 channel with the overlay that I posted above.

But, I do like the idea of adding an xdg-open patch to the derivation. Might look into that.

1 Like