💾 Archived View for idiomdrottning.org › visp captured on 2023-06-16 at 17:01:04. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
Even though I don’t use Firefox normally, I’ve been using it to read EPUB books because I like how it’s three columns. What I don’t like is how those columns get completely mabla at the end of each chapter.
So instead I set up this li’l shell script to read the EPUBs via Pandoc using a custom template for the ConTeXt PDF engine.
You can git clone https://idiomdrottning.org/visp for a repository of all the code from this article.
Here is the template, it belongs in ~/.pandoc/templates/ellenread.context so pandoc can find it.
It’s made for a 1600×1200 screen and gives me three columns and tiny letters.
That 1600x1200 is currently hardcoded (as width=423.33333mm,height=317.5mm), I measured it out in Inkscape. It’s not just for the aspect ratio, it also affects the font size relative to your screen, which is why it’s good to get it right if you are modifying this script.
I made this shell script, visp to try to play nicely with Calibre. It depends on pandoc, sqlite3, calibredb and context to be in your path. And mupdf-gl but you can change that to any PDF viever.
It takes one argument, a epub file. It can be any random epub file, like "/tmp/0123456789.epub" that you’ve gotten from a publisher, or whatever.
It checks to see if that book is already in Calibre. If it is, it is gonna read Calibre’s version instead. If it’s not, it adds it to calibre and then reads Calibres version. This is nice because I can just be “sloppy” and open EPUBs from the download directory or whereever I find them and visp will organize them for me without clobbering any organization it, or I, have already done.
Then, it checks to see if there is already a PDF-version of that book in Calibre, either a publisher-supplied version or one that this script has made. If not, it calls pandoc with ConTeXt to make a new one with the ellenread template above.
Then finally it calls mupdf to open the document it found or made.
Yeah, I know that that’s a lot to setup but from then on, just visp
blablabla.epub and up pops PDF on my screen.
Or if you are searching for files already in Calibre, just visp bla
bla bla for the same thing, you don’t have to supply a filename, just any search terms.
I also extracted just the first few lines of that script into epubid, that just takes an epub, adds it to Calibre if it’s not in there but returns the local Calibre book id either way.
Getting the book id from Calibre can be useful for when calling calibredb for various other things, like add_format.
Example usage:
calibredb add_format $(epubid The_Fantastic_Novel.epub) The_Fantastic_Novel.mobi calibredb add_format $(epubid The_Fantastic_Novel.epub) The_Fantastic_Novel.pdf
when you want to add TheFantasticNovel.epub, TheFantasticNovel.mobi and TheFantasticNovel.pdf to Calibre all in one go and they’re all in your current shell dir.
Remember that add_format can overwrite your Calibre’s database, which is good when you want to overwrite the visp-generated PDF with a publisher-supplied one, but bad because it can accidentally clobber. That’s why visp tries to take such good care to see that there’s not already a PDF in there.