This post is the third in a series on my integration with a VT220-like (VT510) terminal, as my ‘daily driver’. The first post in this series is available here.

RSS

Some say RSS or “Really Simple Syndication” is dead, but I think you just need to know where to look for feeds. A lot of modern content management systems (CMSs) have RSS feeds built in, so some organisations may unwittingly publish them. Many more still choose to publish RSS with a small summary of their articles, baiting readers to click on the link for more. (Tangentially, this can be gotten around if you’d prefer to read everything in your RSS reader without going to an external website.)

I have RSS feeds from news organisations and blogs that I follow, and I like being able to effortlessly check in on these throughout my week. I use newsboat (formerly newsbeuter) to do this.

Bookmarking (Integration with Pinboard)

I’ve used Pinbaord for more than 10 years and it’s a great example of a website that continues to does what it says on the tin. It has an API that allows me to send my links to it from the command line. The script that I use, for RSS and web browsing (discussed more later on) is shown below. I have modified this script to enable Lynx to use it as well as newsboat.

!/bin/sh
# newsbeuter bookmarking plugin for pinboard
# (c) 2007 Andreas Krennmair
# documentation: https://pinboard.in/api

username="YYY"
token="XXX"

mode="$1"

case $mode in
        "newsboat")
        url="$2"
        title="$3"
        desc="$4"
        tag="via:newsbeuter"
        ;;

        "lynx")
        url=$LYNX_PRINT_URL
        title=$LYNX_PRINT_TITLE
        tag="via:lynx"
        ;;

        "lynx-description")
        url=$LYNX_PRINT_URL
        title=$LYNX_PRINT_TITLE
        echo ""
        echo "Enter description: "
        read desc
        tag="via:lynx"
        ;;
esac

output=`curl -G -s "https://api.pinboard.in/v1/posts/add" --data-urlencode "auth_token=${username}:${token}" --data-urlencode "url=${url}" --data-urlencode "description=${title}" --data-urlencode "extended=${desc}" --data-urlencode "tags="${tag}"" --data-urlencode "toread=yes"`

output=`echo $output | sed 's/^.*code="\([^"]*\)".*$/\1/'`

if [ "$output" != "done" ] ; then
 echo "$output"
fi

In order to save a bookmark in newsboat, I have the following configuration lines in ~/.config/newsboat/config:

# -- bookmarks -----------------------------------------------------------------

bookmark-cmd "~/bin/bookmark.sh newsboat"
bookmark-interactive no
bookmark-autopilot yes
bind-key b bookmark

Viewing

Sometimes I might want to visit a link directly from newsboat. Luckily this RSS reader has support for specifying a browser to use. Through the following configuration line in ~/.config/newsboat/config, I set a terminal-based browser (more shortly):

browser "/usr/local/bin/lynx -cfg=~/.config/lynx/lynx.cfg %u"

The file ~/.config/lynx/lynx.cfg is an optional argument that allows me to specify a configuation file. It is not necessary.

Web Browsing

In order to get the most out of Lynx, I’ve found the following settings necessary for general browsing. These include allowing cookies, setting up a jumpfile (more later), a default bookmarks file.

SET_COOKIES:TRUE
ACCEPT_ALL_COOKIES:TRUE
PERSISTENT_COOKIES:TRUE
COOKIE_FILE:~/.cookies
COOKIE_SAVE_FILE:~/.cookies
FORCE_SSL_COOKIES_SECURE:FALSE

JUMPFILE:~/.config/lynx/jumps.html
DEFAULT_BOOKMARK_FILE:~/.config/lynx/lynx_bookmarks.html
BOOKMARK_FILE:~/.config/lynx/lynx_bookmarks.html
DEFAULT_EDITOR:vim

Bookmarking (Pinboard.in integration)

As with my RSS reader, I have managed to make Lynx “support” (somewhat) my desired workflow of saving pages in pinboard. In order to do this, I added a ‘PRINTER’ output to the browser, and specified this as script. pinboard-comment asks me (not very graciously) if I would like to add commentary text to send to the API call to Pinboard, which is saved as a comment in the bookmark entry.

PRINTER:pinboard-comment:~/bin/bookmark.sh lynx-description %s:TRUE
PRINTER:pinboard:~/bin/bookmark.sh lynx %s:TRUE

Lynx does have a ‘DOWNLOADER’ functionality too, however from what I could determine, this function does not provide access to the necessary environmental variables that PRINTER does in order to support scripting inputs to the Pinboard API.

Screenshot of Lynx terminal in print dialogue, saving bookmark to Pinboard

Saving a bookmark to Pinboard in Lynx

Jumpfile

A jumpfile is a quick way of defining favourite sites you’d like to be able to access via the keyboard, with a quick typing of j then a predefined shortcut. For example, the following jumpfile allows me to type jg<enter> to get to Google quickly, in Lynx:

<html>
<head>
<title>Shortcut List</title>
</head>
<body>
    <h1>Shortcut List</h1>
  <b>Name</b>&nbsp;&nbsp;&nbsp;<b>Link</b>
<dl compact>
<dt>?<dd><a href="file://localhost/Users/joel/.config/lynx/jumps.html">This Shortcut List</a>
<dt>g<dd><a href="https://google.com">Google</a>
</dl>
</body>
</html>

The setting to enable this jumpfile is given in the configuration shown in the previous section.

Various Lynx jumpfiles are available for sampling from the internet.

HTTP/1.0

The most commonly used version of Hyper Text Transfer Protocol (HTTP) is HTTP/1.1. Correctly implemented servers are required to be backwards compatible with HTTP/1.0 requests, however this unfortunately is not always the case. In particular, while actioning an email this week I was served a 308 (Permanent Redirect) header, which was only defined from HTTP/1.1. Lynx didn’t know what to do, and did not redirect.

This is just a small pitfall to be aware of!

Gopher

Gopher was a popular internet protocol, preceeding the World Wide Web. Interestingly, the Gopher protocol is seing somewhat of a resurgence (renaissance?) lately, and Lynx still works with the text-dominated protocol.

Gopher has useful sites that are text-only versions of well-known sites, such as:

  1. Reddit
  2. Bureau of Meterology Melbourne Forecast
  3. Hacker News
  4. The Guardian
  5. Wikipedia
  6. Metafilter
Screenshot of Lynx terminal viewing a Gopher Reddit gateway

Text-only Reddit via Gopher protocol

Gopher is amazingly fast on a 100Mbit connection (as you would expect), and great for privacy (no cookies, ads or monetisation whatsoever).

Security

Passwords

I use 1Password, and when it comes to logging into websites, it’s quite easy to integrate this into workflows. For example, once setup, you can login and make queries to put your passwords on the clipboard, ready for pasting into Lynx.

eval $(op signin my)
op get item <item> --fields password | pbcopy

Locking the screen

The VT510 has a feature that dims the screen when content has remained unchanged for approximately 30 minutes. This is great, however with a live-updating clock and news feed on the screen, the display doesn’t discern that this is just ‘background noise’ and it should go to sleep anyway. I wanted a way to quickly and easily shut off the screen. I viewed the benefit of locking the terminal to be a bonus.

I installed bashlock and bound it to the tmux combination of control-x. This displays a static ‘please log in’ screen, enabling the monitor to turn itself down to save itself.

# Screen lock
bind-key -n C-x lock-server
set-option -g   lock-after-time 0
#set-option -g   lock-server on
set-option -g   lock-command "~/bin/bashlock/bashlock"

I did make some changes to bashlock, as I found that the VT510 would not reconnect after being ‘locked’. The VT510 also doesn’t display any feedback until the terminal is successfully unlocked. I’m not sure why right now.

I added the following line to the near-bottom of /etc/sudoers, to allow my user (who runs bashlock to run launchctl):

joel		ALL = (root) NOPASSWD:NOEXEC: /bin/launchctl

and made the following changes to a part of bashlock:

        if [ "$?" -eq 0 ]; then
            echo "Welcome back!"
            echo ""
		    sudo launchctl unload -F /Library/LaunchDaemons/serialconsole.plist
		    sudo launchctl load -F /Library/LaunchDaemons/serialconsole.plist
            exit 0
        else

This reboots the Launch Daemon, and kicks the VT510 into action again after unlocking. Meanwhile the screen stays nice and static when I remember to lock the terminal for long periods away, ensuring that CRT burn-in is minimised.

Result

This is the end of my series on my DEC terminal. I hope this shows you the power of a text-based approach to computing, and the remarkable ability for 30+ year old hardware to still be useful parts of our modern lives.

Photo of VT510 displaying a Gopher page via Lynx

Shot of VT510 displaying a Gopher page via Lynx

More Information

  1. Newsboat Documentation
  2. Lynx key commands
  3. Lynx user guide
  4. Sample Lynx jumpfile
  5. Lynx multi-bookmarks (not implemented here)
  6. Lynx print script variables
  7. Scripting print functionality in Lynx
  8. 1Password CLI
  9. pbcopy