💾 Archived View for tilde.team › ~smokey › logs › 2021-12-05-ereader.gmi captured on 2024-08-18 at 22:45:33. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-06-11)

-=-=-=-=-=-=-

A Journey of E-Readers, Gemini, and Scripts

E-readers

Hey all, Smokey here! Today, I would like to talk about the newest addition to my technological arsenal: The Kobo Libra 2 E-Reader!

Before this, my only ebook reading experience has been with your standard LCD android tablets. They served me well enough over the years. However when my reading tablet finally bit the dust I decided it was finally time to dip my toes into a true, proper ebook reading device. Thus began my journey.

Already having a large library of epubs, CBZs, and audiobooks, I wanted something that could support as much of my files out of the box as possible. I didnt want to go down the Amazon route either, my own past experience with kindles didnt exactly go well with me. I do not enjoy walled garden ecosystems or predatory advertising practices to say the least.

After doing some research I decided on the kobo libra 2 as it fit my price range and i was very impressed with what i saw in the reviews. Meeting the criteria i wanted in a e-reading device, i went for it. And so here we are!

So far, I am very impressed with it! The E-ink technology truly is a step up when it comes to displaying text and monochrome images. The sunlight actually works with me instead of against. I had no issues getting the files transfered over, just a regular usb transfer will do. Setting up a FTP server and connecting to it with the experemental browser is also certainly possible.

I also found this awesome web service for sending epub/mobi to kobos and kindle fires.

Gemini

I A few articles have stuck with me when it comes to ereading over my time browsing the gemsphere. Soldierpunks ideas on offline computing come to mind easy, as well as many other peoples efforts to automatically convert gemini content to offline formats and sync it to their PDA and e-reading devices. Now that i truly get what the fuss is about, i am more motivated than ever to save webpages and gemini capsules for offline reading.

Creating epubs from webpages its fairly straight forward, I use the EPubPress on Firefox. No fuss no muss, it gets the job done. Gemini, however, is a whole nother' beast entirely. I had absolutely no idea where to start. So, I began with a few searches on geminispace.info. queries like "epub", "gemini to epub", "ereader". Hopefully to see what people had done before me, take inspiration from their results.

On a side note, It occured to me at some point that it is easy enough to use a web proxy with firefox and print out epubs with the forementioned epub addon. But whats the fun in that?! No proxies allowed in MY house!

Some of the articles that caught my eye

Antenna to epub by eapl.mx

gemini to epub by kelbot

offline gemini script by kelbot

Scripts

Scripts are essentially sets of instructions which can be chained together to form complex operations. Anyone who is familiar with UNIX has run a command in the terminal once or twice before. Just wanted to clarify incase anybody is new to the concept. There are more technically correct definitions, but I think you can get the idea.

Starting the process

Admittedly, I didnt do a whole lot of searching. But also I didnt need to. That last link, "offline gemini script" was just what was needed to get a grasp of what a program that can turn capsules into epubs would look like, Complete with the source for the bash script. and a set of instructions for installing. The original scope of what i wanted was a fairly simple manual gem to epub script, this opened my eyes to the autonomous bliss that was possible with a little know-how and elbow (er, finger) grease.

I was certainly very interested to try it out. Already having calibre installed, I choose to install gcat instead of gmni. After downloading gcat, you need to tell the $PATH what directory its in.

Adding a directory to $PATH

I've never added any directory to the $PATH directory before as was needed for gcat, but a quick internet search was all it took to learn how and why.

Enter this command in the terminal to edit bashrc

nano ~/.bashrc 

and put in a new line at the very end

export PATH=$PATH:/your/file/path/gcat

tip: to easily get the file path first open your file manager, mouse up to top where it shows path, right click and select "copy". Paste into terminal with ctrl+shift+v or right click and select "paste".

Afterwards save your edits to the bashrc file with ctrl+o and exit nano with ctrl+x. Open a new terminal and type in the command

gcat

and it should display

Usage:
gcat gemini://gemini.circumlunar.space

You're good to go with gcat hopefully.

All thats left is to copy the script source provided and save it into a .sh text file, then allow the file to to be executable. Its worth noting that by default kelbot has it written to create two copies of each book, one for his palm and one for the ereader. I was only interested with the epub version so deleted the blocks of script containing .pdb. Also, you need to replace all instances of gmni with gcat if you did it that way.

Running the script

I ran it with anticipation, but knew too well that nothing is ever that easy. Suprisingly the script actually did work, to an extent. the epubs laid before my eyes in the dailydigest folder. I opened them eagerly, only to find that they contained exactly one page. The cover. What a tease man!

No doubt, the result is from my sheer incompetence with scripting. I failed to do something right, probably when substituting gmni with gcat. Oh well. I find it funny that they are so humble about being a 'complete beginner' yet I can only understand 15% of the parameters of their script at most. What does that make me? None the less, ive come too far by this point.

Resolve

If I really wanted a gemini to epub program, then I would have to code one myself from scratch. built upon my own meager, fleeting understanding of bash and some internet searches. At least I had gcat and ebook-convert to work with.

Fortunately, 15% understanding is still enough to get a sense for what need to happen to do the thing.

My gemini to epub script

So, I set out on my herculean task of cobbing together a script that would actually do the thingy. Sorry for using such technical terms :p After staring at kelbots original script for inspiration and learning some of the more basic functions of bash script, i whipped this together.

I present to you: the Super-Duper-Simple Gempubtron 9000. Thats a marketable name, right?

#!/bin/bash
#Make temporary text file
tmp_d=$(mktemp -d)
tmptxt="$tmp_d/tmptxt.txt"

#Delete temporary text file after script is done
trap 'rm -rf -- "$tmp_d"' EXIT

# Ask user for Gemini URL
echo Please input your Gemini URL:

#read user input and write out to variable "url"
read url

#Ask for title of book
echo what would you like the title to be? NOTE: NO SPACES! Please use underscores and rename after process is complete

#Read user input, write out to variable "title" to be used later for final epub title. 
read title

#use gcat to fetch text from gemini url, output text to temporary file
gcat $url > $tmptxt

#let the user know whats going on
echo Finished raw text download! Converting to epub...

#run ebook-convert to turn raw text file into an epub file, direct the epub file to go output folder. Change the path to whatever. 
ebook-convert $tmptxt $HOME/Documents/$title.epub --title=$title

#Tell user process is finished
echo Process complete! Enjoy your E-book!

Beautiful, innit? Im quite proud of myself for this one, as it is my first ever homemade script that does something useful. Unfortunately, for whatever reason trying to execute this through the executible .sh file by itself wont work. To run the script you need to open the terminal, cd to the directory containing the script, and run

bash script.sh

Its wierd that it only works this way, and the script is rough around the edges. Buuut it works for me so ill take it! I think that this is about as simple as you can get a program like this to be, hopefully simple enough for anyone to understand and build on.

Its obvious where where my little script falls flat compared to the ones made by kel and eapl. The formatting of the epub itself is extremely simple and somewhat disjointed. This comes as no suprise, because all weve done is pulled raw text from the capsule and stuffed it into an epub. Looking at eapls sample antenna epub, it looks much nicer than the one my script produces. It now dawns on me that the other 85% of kels code that I cant understand is all probably formatting configurations and parameters. The price for simple code is a lack of customization. I tried finding documentation to get a jist of whats going on with that stuff but all those args and awks are just nonsense to me, maan.

closing statements

Maybe in the future I will understand a little more about bash scripting to the point of improving the quality of formatting in my epubs. Maybe someone else will make a superior gem to epub tool that i can actually compile which renders my script obsolete. I still really want to make kels script work, which first means i need to get gmni compiled and its not going well on that front. In the meantime, I am satisfied that I managed to use the tools at my disposal in a way to create my first truly functional script thats actually useful.

Its at this point that I feel the need to thank kelbot in particular for his contributions. My knowledge of bash scripting is near nonexistant. I use the terminal well enough to just barely compile dependency tools from source if im that lucky. It is a huge relief to come across his article, and the script source supplied with it. It helped me examine the mechanisms needed to create my own program where otherwise I wouldnt have had the experitse to fit it all together. The importance of documenting and sharing cant be understated. Thanks kelbot!

I enjoy the idea that by documenting my journey and trials in the land of gemini I can help someone in the future who is where i was.

"If I have seen further it is by standing on the shoulders of Giants." - Isaac Newton

I hope that you found this article entertaining or useful or both! Got feedback? Shoot me an email at smokey(at)sdf.org

Back to my homepage