3

Where and how can I run the ebook-convert script for calibre from the console?

nicholas@gondor:~$ 
nicholas@gondor:~$ flatpak info com.calibre_ebook.calibre

calibre - The one stop solution to all your e-book needs

          ID: com.calibre_ebook.calibre
         Ref: app/com.calibre_ebook.calibre/x86_64/stable
        Arch: x86_64
      Branch: stable
     Version: 5.23.0
     License: GPL-3.0
      Origin: flathub
  Collection: org.flathub.Stable
Installation: system
   Installed: 360.9 MB
     Runtime: org.freedesktop.Platform/x86_64/20.08
         Sdk: org.freedesktop.Sdk/x86_64/20.08

      Commit: 13464e660f35716a725261af4b45d3abc199a3ce52ebdd9ee887c7ae623b5873
      Parent: 4f7f3b603f31cc781caf8260f887118a1bb466748891c9e122826728e25d3eed
     Subject: Update calibre-5.22.1-x86_64.txz to 5.23.0 (9184a3f3)
        Date: 2021-07-11 19:56:21 +0000
nicholas@gondor:~$ 
nicholas@gondor:~$ uname -a
Linux gondor 5.8.0-59-generic #66-Ubuntu SMP Thu Jun 17 00:46:01 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
nicholas@gondor:~$ 
nicholas@gondor:~$ man calibre
No manual entry for calibre
nicholas@gondor:~$ 
nicholas@gondor:~$ ebook-convert
Command 'ebook-convert' not found, but can be installed with:
sudo apt install calibre
nicholas@gondor:~$ 

Installed via flatpak because:

1.) calibre is, or at least wasn't, in snap repo 2.) have had problems with the apt version in the past

more of a flatpak usage q than specific to Ubuntu. Probably a calibre or flatpak man page will explain where or how to launch the conversion script -- but which man page?

tried:

nicholas@gondor:~$ 
nicholas@gondor:~$ flatpak run com.calibre_ebook.calibre.ebook-convert
error: app/com.calibre_ebook.calibre.ebook-convert/x86_64/master not installed
nicholas@gondor:~$ 
nicholas@gondor:~$ flatpak run com.calibre_ebook.ebook-convert
error: app/com.calibre_ebook.ebook-convert/x86_64/master not installed
nicholas@gondor:~$ 

see also

how to launch flatpak calibre from the console?

Nicholas Saunders
  • 1,054
  • 4
  • 16
  • 37

3 Answers3

4

According to Debugging section of Flatpak guide and man flatpak-run you can use special --command argument.

So we need to enter the shell by

flatpak --command="sh" run com.calibre_ebook.calibre

and then run conversion here:

[ com.calibre_ebook.calibre ~]$ ebook-convert in.epub out.fb2
1% Converting input to HTML...
InputFormatPlugin: EPUB Input running
on /home/user/in.epub
...
Converting XHTML to FB2 markup...
FB2 output written to /home/user/out.fb2
Output saved to   /home/user/out.fb2
[ com.calibre_ebook.calibre ~]$ exit
$ ls in.epub out.fb2
in.epub  out.fb2

Or more straight-forward:

flatpak --command="sh" run com.calibre_ebook.calibre \
-c "ebook-convert ~/in.epub ~/out.fb2"
N0rbert
  • 97,162
  • 34
  • 239
  • 423
3

As pointed out in the answer of @N0rbert, you need to use the --command switch which allows you to execute the ebook-convert script:

flatpak --command="ebook-convert" run com.calibre_ebook.calibre input.epub output.epub

For simplified usage and compatibility with scripting you can create an executable script named ebook-convert and place it in ~/.local/bin:

#!/bin/bash

flatpak --command="ebook-convert" run com.calibre_ebook.calibre "${1}" "${2}"

Then you can simply use ebook-convert input.epub output.epub from the command line or from a user script.

sfera
  • 131
  • 2
  • Or make an alias: `alias ebook-convert='flatpak --command="ebook-convert" run com.calibre_ebook.calibre'"` – red_trumpet Mar 17 '23 at 19:12
  • @red_trumpet The alias is great for manual conversion but won't help if the conversion needs to be triggered by a script. – sfera Mar 18 '23 at 22:49
1

I don't know how flatpak works, but I was able to find the script like this:

$ which calibre
/usr/bin/calibre
$ ls -artl /usr/bin/calibre
lrwxrwxrwx 1 root root 20 Jul  2 20:18 /usr/bin/calibre -> /opt/calibre/calibre
$ cd /opt/calibre
ls -artl ebook-convert
-rwxr-xr-x 1 root root 6400 Jun 25 14:54 ebook-convert
mondotofu
  • 721
  • 4
  • 8