Readwyn 0.1.0

How to open and read an EPUB file on Linux

An EPUB needs an ebook reader, and once one is installed you open the file from your file manager like any other document: right-click it and pick the reader under “Open With…”. Several free readers exist for Linux. Foliate reads EPUB, MOBI, Kindle files, FB2, CBZ and PDF, and comes from Flathub, the Snap Store, or the packages of Arch, Debian, Fedora and openSUSE. KDE's document viewer Okular lists EPub among its formats too. Readwyn, which this site is about, opens an EPUB from the file manager as well, and can keep it in a library afterwards.

Open With, and the default app

Ubuntu's desktop is GNOME, and GNOME's help describes the right-click route: the apps that handle the file type appear at the top of the menu, and “Open With…” lists the rest, with “View All Apps” for the ones that didn't declare the type (GNOME Help, “Open files using other applications”).

To make a reader open every EPUB on a double click, the same GNOME page gives the menu route: right-click an EPUB, choose Properties, open the Open With tab, select the reader and click “Set as default”.

From a terminal, the freedesktop tool xdg-mime does the same, run inside your desktop session. First ask what the system thinks the file is, then which app handles that type:

xdg-mime query filetype "Middlemarch.epub"
xdg-mime query default application/epub+zip

The first should print application/epub+zip. The second prints the .desktop file of the current default. To change it, pass the .desktop file of the reader you want:

xdg-mime default com.readwyn.Readwyn.desktop application/epub+zip

The xdg-mime manual notes that the app must already be installed in the desktop menu, that its .desktop file must list the type, and that you shouldn't run the command as root. Run the query default line again to check that the change took.

What Readwyn does with the file

The deb and rpm packages (Ubuntu, Fedora) put a menu entry on the system that declares application/epub+zip, so Readwyn turns up under Open With for an EPUB straight after the install. It doesn't take over the type: the install leaves your existing default alone, and xdg-mime default above is how you hand EPUBs to it. The same entry declares MOBI, AZW3, PDF, CBZ, CB7 and CBT, and the package adds the types that an older system lacks, including two of its own for .pdb and .oeb books.

What you see depends on where the book already lives:

  • A book in the current library opens at your saved place, with no message.
  • A book in another library switches to that library, opens at the saved place, and says so in a toast, for example “Opened from your Classics library.”
  • A file in no library opens at once, outside every library. Another edition of a book you own counts here, because Readwyn matches the exact bytes of the file, not the title.

A file in no library reads like any other book, with Contents, Find, Text and dictionary lookup all working. The top bar shows “Library” as the back button and a chip that says “Not in your library” (the title joins them in a wide window), and the footer ends with “Your place is not saved until you add this book”. Nothing is recorded: no position, no reading time, no stats. Highlights and bookmarks wait too; select a passage and the popover offers “Add the book to keep highlights” beside Copy and Find. Each time you open the file, it starts at its first page.

The add button says “Add to My library” on a fresh install (it names your current library), with an arrow to pick another if you have several. The book then goes through the usual review of “Add books”, and you stay on the same page, which is saved from then on. Readwyn reads a copy of the file in its cache folder, so the book stays open if you unplug the USB stick it came from.

An EPUB 3 opens as it is. An older EPUB 2 is converted to EPUB 3 first, the same way a book in the library is, and if that conversion fails the file opens unconverted. A file that isn't a book, or is damaged, gets a toast (“Readwyn can’t open “name”. The file is damaged, or it isn’t a book.”) and the app stays as it was.

When the app is already running

A second double click doesn't open a second Readwyn. The new start hands the file to the app that's running and quits, and the book opens within 2 seconds. Under Wayland an app can't take the focus by itself, so the window may only ask for your attention rather than jump to the front. Opening several files at once opens the first, and the toast says how many didn't: Readwyn holds one book at a time.

For how the reader and the windows behave on each desktop, see Read ebooks on Linux with Wayland or X11. The rest of the Linux app is in An ebook manager for Linux.