-- Leo's gemini proxy

-- Connecting to tobykurien.com:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; lang=en

In praise of elinks


As I spend more time in text-based tools on the command line, I've become quite appreciative of the elinks browser. I've been building various portable Raspberry Pi based computers over the last while and I've realised that web browsers like Chromium and Firefox are the bottlenecks in terms of performance, because they are so resource-hungry. Netsurf is a nice alternative, but works quite poorly if using a touch-screen input, for example scrolling is quite finicky.



At first I was torn between elinks and w3m, the latter has a version that can display inline images, even in a terminal! However, image-heavy sites tend to show up performance problems and rendering issues in the latter, where images are sized almost randomly; some too large, others too small. So I dug into elinks a bit more, and now I think it's one of the best browsers out there, and can do a few things even Chromium or Firefox cannot! Think that's hyperbole? Read on...


Smolnet


For starters, elinks supports a wide range of protocols, especially smolnet ones! Gopher? Check! Finger? Check! NNTP? Check! Dare I ask... Gemini? Check! Caveat: must be enabled during compile, on the newer "felinks" fork of elinks that most distros now use. Also currently only supports a single client certificate for all sites, from what I can tell.



The "felinks" fork of elinks



At this point, it's worth pointing out that many distros (e.g. Debian, Raspberry Pi OS) have very old versions of elinks that lack support for some of the newer features I'll mention here. It's well worth downloading the source code and compiling your own copy, which is surprisingly quick and easy, took just around 4 minutes on my Pi 3b. Alternatively, get it using Nix package manager, which by the time you read this, will hopefully have the latest version compiled with Gemini support.



My request to enable Gemini in elinks for Nix packages, which is merged!



Cool features!


Some cool and unexpected features of elinks:



- CSS support! The orange site actually looks orange, and renders beautifully as per your terminal's font settings, i.e. no need to bump up the zoom level.

- Highly configurable! I'll expand on this below, but it has a comprehensive setup dialog allowing you to change a lot of things about how it renders and handles links, amoung other things.

- TUI! Can't remember the keyboard shortcut to open a new tab? Use the TUI menu! Simply press Esc and you can navigate the beautiful "Turbo Vision" inspired menu easily with your arrow keys, and see the shortcuts for the menu items next to them. Aha! It's just "t" to open a new tab.

- Yes, tab support! Simply press "t" to open a new tab, then "<" or ">" to switch between tabs.

- Great terminal support. If you have a 256-color terminal (e.g. lxterminal on Raspberry Pi), and you install "fonts-noto-color-emoji" package, you get wonderful emoji rendering so you can enjoy Gemini sites in all their glory!

- Status bar, showing you what URL a link points to, and optionally you can add a clock and status "LEDs" for a great full-screen browsing experience.

- Configurable Document URI passing: this is a big one, and I'll expand on this in the next section.

- Touch screen and mouse support works on most of my devices, which means I can touch-to-click a link or mouse-scroll-wheel to scroll the page.



I believe you can even enable JavaScript support on elinks, but I haven't tried, since that is the thing I am actively trying to avoid here.



YouTube, images, and audio, oh my!



One of the main use cases for my Gemini site is to scrape video and audio content from (often horrendous) websites to make them easy to access and view, even from my text-based browsers. As an example, I watch sports highlights I am interested in by scraping them from our local SuperSport website into a Gemini page (see my capsule homepage) to avoid all the JavaScript popups and other dark patterns on the actual website. However, the links to the videos are sometimes on YouTube, or are m3u8 playlist files that need to be passed to player to view. On a Raspberry Pi in particular, hardware-accelerated video playback is not easy to achieve; sometimes the default install of RPi OS has it enabled for Chromium, sometimes an update breaks it. However, with mpv I can configure it for the best hardware acceleration, and the best video resolution, so that it's always the best way to view video or listen to audio (others may have similar joy with vlc). Unfortunately, a browser like Chromium won't allow me to send the video or audio to an external player like mpv, but elinks does!



A lesser known feature of elinks is that you can set up a key to work like a right-click on a link, it's in the options manager under "Document > URI passing". It's not very intuitive how this works, but you can add command-line tools to pass the URI to, and then assign a key (I used the backtick key) to trigger it. This means that, to watch YouTube for example:



- I have mpv and youtube-dl installed and up-to-date

- I visit an Invidious instance and search for the video I want to watch

- To see the thumbnail of the video, I press "v" while the relevant "[IMG]" link is highlighted, and it opens the image in the configured image viewer (I recommend fbi or feh for CLI and Eye of Gnome seems to be the default for GUI).

- To watch the video, I highlight the link to the video, then press the backtick key and a menu pops up.

- I have configured the following options in the menu: mpv, mpv video, mpv audio, text. The corresponding commands for these are: "mpv %c", "mpv --no-audio %c", "mpv --no-video %c", "echo %c > /tmp/url". The last command simply writes the URL out to the /tmp/url file, which I can then use elsewhere (like sending off by email or using youtube-dl to download).

- I simply select "mpv" and after a short delay, the video loads in mpv!

- BTW this also works for websites that embed YouTube videos on the site (typically an iframe).



Invidious instances



The above means that I can watch YouTube or other websites (supported by youtube-dl) right from elinks, even from a low-powered device like a Raspberry Pi 3b! It makes much of the modern web accessible to older or under-powered devices, for example browsing Hacker News and following links from there almost always works and gives you a consistent Gemini-like experience (no popups, same font and text-size everywhere, etc.). Some sites can be hard to read if their colours are ill-defined, but simply pressing "%" will remove the CSS colours for plain black-and-white text.



Conclusion



There are many other things I like about elinks, but this post was simply to draw attention to those who might be interested in browsing the Smolnet and the web on a low-power machine, or from the CLI. I love the elinks experience so much that I tend to use it even on my main laptop, only opting for a full-fat browser when I need to browse a JavaScript-required website like banking or shopping. It did take me a long time to "get it", and to find the optimal configuration, so for your covenience, I'm linking my elinks.conf file below that you can simply copy into `$HOME/.elinks/elinks.conf` to try for yourself. Enjoy!



My elinks.conf file






__

Home

Email me

-- Response ended

-- Page fetched on Tue May 7 20:19:04 2024