Blog: Rev. Fr. Robert Bower

Lynx Configuration Five Ways

When it comes to terminal based web browsers I only know of two that are actively maintained. Today I am going to write about one of those, Lynx. Lynx can be very frustrating to the new user or maybe it was just me. What I found frustrating about Lynx was how to configure it. Lynx actually is not hard to configure once you know that Lynx has five different methods to configure it with some of the methods overlapping but many options being unique to a method. None of the methods are difficult to do. It just knowing that different things are configured in different places. I am not going to show you how to configure Lynx but what the five configuration methods are and where to find more information about them in the manual.

The five methods are:

  • lynx.cfg

  • .lynxrc

  • lynx.lss

  • Command Line options

  • Environment Variables

Lets summarize at each method.

.lynxrc

The .lynxrc configuration file holds the options found in the Options menu that can saved from session to session. Remember not all options can be saved from session to sessions using the Options menu. More information about the Options Menu and .lynxrc can be found here

lynx.cfg

The lynx.cfg configuration holds most of the other configurations for Lynx such as the start page and the index page. When you install Lynx depending on your distribution there may only be a system wide lynx.cfg. I would suggest copying the file to your home directory and then customizing the file to fit your needs. Details of the lynx.cfg file can be found here

lynx.lss

The lynx.lss configuration file holds the style settings for Lynx, such as color. Again, when you install Lynx depending on your distribution there may only be a system wide lynx.lss. I would suggest copying the file to your home directory and then customizing the file to fit your needs. The best way to learn about lynx.lss is just play with the file. If you break it just copy it again from the system wide file.

Environment Variables

You can set environment variables for Lynx so it knows where to look for items as it starts up. For example, Lynx looks it the root of the user's home directory for lynx.cfg and lynx.lss but lets say you want to follow the current standard of putting configuration files in the /home/user/.config/lynx directory. You can set add environment variables to change that path in your .zshenv file so Lynx looks for the configuration files in a different location.

An example being:

export LYNX_CFG=/home/yourusename/.config/lynx/lynx.cfg
export LYNX_LSS=/home/yourusername/.config/lynx/lynx.lss

More information can be found here

Lynx command line

If you want to start Lynx with certain options set that can not be set by one of the configuration files or you want to just change something for one session Lynx has many different command line options.

The two I use the most -useragent= and -cookies. The -useragent= flag lets me set user agent string whatever I want. Usually I change it from lynx to l_y_n_x so that I can go to sites that usually block the Lynx browser.

I also use -cookies if I want cookies set to ignore.

More information can be found here

Gotchas

There are a few gotchas in Lynx that makes configuration difficult until you know about them.

One is Lynx assumes your bookmark files and cookies files will be in the root of your home directory and prepends the path with /home/yourusername/ for paths listed in your .lynxrc file.

For example, lets say you want to you want to put the bookmarks file in your .local/share/lynx directory. In the .lynxrc file you would only put bookmark_file=.local/share/lynx/lynx_bookmarks.html Lynx will prepend the path with /home/username/

Another gotcha is in the Options menu. Any option ending in a (!) can only be changed for that session only using the option menu. A user can change the user agent in the options menu but once you quit Lynx the change is gone.

Hopefully this gives you a simple breakdown of where Lynx looks for different customization information.

Zettelkasten ID lynxconfiguration-2020-07-04-1143

Using MPV with Newsboat

I use Newsboat to read RSS feeds including mp3s and YouTube Videos. I want to be able to watch YouTube videos from the command line and not from the browser. The standard suggestion is to create a macro in Newsboat and pass the YouTube url to mpv. MPV then takes the url and plays the video. Here is where I was having issues. The URL you see in your browser for the YouTube video is not actually the URL for the video that gets played on your computer. The URL you see in your browser is the "doorway" to the actual video URLs. For each video there are several URLs, ones that are video only, ones that are audio only, ones that are high quality, and ones that are low quality. I find that sometimes, not always, MPV has trouble finding an URL to play. Sometimes it will work fine, sometimes it will play the audio only URL, and sometimes it cannotnot find a URL to play at all. This problem occurs even with the most up to date youtube.lua file for MPV.

The one program I find that is very good at keeping up with the changes at YouTube is youtube-dl. It is a command line program that lets you download YouTube videos. YouTube-dl can be used to download the desired video and then the video can be watched with MPV. But what if you want to stream the video and not download it. YouTube-dl has a neat little flag -g which gets the video's URLs but doesn't download them. Youtube-dl also has a -f flag which allows the user to specify what format they want. One of the options is best. So if you use youtube-dl -g -f best http://youtube.com/watch?=videoidgoeshere youtube-dl will send to stdout the URL of the best quality video. This URL MPV can play without any issues.

So here come a bash script to the rescue:

 #!/bin/sh  
 youtube-dl -g -f best $1 | xargs mpv 

This little script has one argument, the URL of the video's YouTube page. Youtube-dl finds the URL of the best quality video and then it is piped to MPV and the video is played.

To call this from Newsboat you need to create a macro.

 macro m set browser "tsp nbyt %u"; open-in-browser ; set browser "lynx"

The macro sets the browser to the script I created called nbyt, then opens the script while passing the URL to it, and finally sets the browser back to the default. The tsp command allows the script to be run in the background so Newsboat is able to do something else.

One key to keep this all working is to keep youtube-dl updated with youtube-dl -U. YouTube is constantly changing things so youtube-dl must be constantly updated so it continues to work.

As always feel free to use the script at your own risk.

Zettelkasten ID mpvyoutube-2020-05-27-0831

Lifetime Bibliography

One of the things I wish I had done years ago was create a catalog of things I have read, viewed, or listened to. A bibliography of things I have digested over my lifetime. In order to mitigate that I am currently working on creating a catalog of my library. If you are old like me it brings up mental pictures of a large wooden cabinet with many an index card filed away. Well the one I am working on is electronic. My system is a simple bash script. I can run the script enter an ISBN number, the script goes out to the Internet, grabs the bibliographical information and insets into a Bibtex file.

What is a Bibtex file and why do I use it over something else?

First and foremost a Bibtex file is a structured plain text. I have been using computers since 1980 and programs have come and gone but plain text format is still here. Anything you want to keep for years and go back to should be plain text. I remember the days when Word Perfect had the market locked down and their format was the standard. Now Word Perfect is a small segment of the market and the file format they use now is not compatible with the format they used back in the day. Does anyone remember Lotus 123? Binary file formats come and go. So for data that you may want for twenty to forty years should be in a file format that is based on plain text.

Bibtex while an old file format is still used today by many of bibliography managers. Is it the best format? Maybe, maybe not but it is very convenient to use because so many tools can read it, including humans. It common use is the reason I chose the Bibtex file structure over something else. I could be replaced in the future. But even if it is, since the file is plain text it would only take a simple SED command or AWK script to put it in the right format. Off the soapbox.

Now to the script.

 #!/bin/bash
 str='https://www.ottobib.com/isbn/'
 str+=$1
 str+='/bibtex'
 xidel $str --extract //textarea >> ~/Documents/Latex/isbn.bib

The script is very simple the first part of the script creates an url. The url is for www.ottobib.com. You can provide the site with an ISBN and it will give you the bibliography entry for the matching ISBN in your requested format. The second part of the script uses xidel to extract the bibloigraphic information from the web page and appends it to my Bibtex file.

Please feel free to use at your own risk.

Zettelkasten ID bibliography-2020-05-20-1140

MPV as an Audiobook Player

To my dismay I can not find a terminal based audiobook reader. I can find plenty of music and even video players that are terminal based but nothing for audiobooks. I was talking to Roman, he is my black lab (think Mr. Peabody with black fur and without the glasses), about this and he suggested using one of the terminal players for music or videos. The problem is having a way to save your place in the audiobook

After much review we decided to use MPV. MPV has a switch --save-position-on-quit this allows you to resume playback where you left off if you quit the program and start it up later. The switch has one limitation it can only save the position for one file at a time. If you use that switch on the playback of multiple files it saves only the quit position for the last file played.

There are two switches I tried --use-filedir-conf which looks for file-specific configuration files in the same directory as the file being played. I tried this option first but I could not get it to be consistency applied. Sometimes it worked as intended and sometimes not. I am assuming the issue was me and not MPV. I may go back later and try to see if I can get this to work.

The second approach I tried was using the --config-dir=. This approach is the one that worked for me.

The first thing I did was create a directory in my current MPV config directory called book1. Next, I created a subdirectory in book1 called watch_later. This is the default directory that MPV will use to store the current stopping point. The new configuration file only has one line in it save-position-on-quit. This file is saved in book1 with the name mpv.conf Whenever this configuration is called it will save your position in watch_later.

Next I created a bash script the started MPV using the configuration file I just created. The script starts MPV with the specified configuration file and plays a playlist I created for the book called book1.m3u

 #!/bin/sh
 mpv --config-dir='/pathto.config/.config/mpv/book1' /pathtoplaylist/book1.m3u

If you listen to more than one book at a time, just repeat this setup for book2 and then for book3 till you get to the number of books you listen to simultaneously.

When you finish a book and want to start a new book just edit the book1 playlist and remove the old book and add the files for the new book.

This configuration allows me to start and stop playing my audio book and have MPV remember which file I left off at and where in that file I left off at.

Zettelkasten ID mpvaudiobook-2020-05-14-0744

Daily Driver

I wanted to write about the computer I use in my office day to day. It is Dell Optiplex 780 with a Core 2 Duo processor, 8 GB of ram, and a 1 TB hard drive. I bought the computer used from Dell after it came off lease. The computer was originally put into service in June of 2010. The only changes I have done to the computer is replacing the 160 GB hard drive with a 1 TB drive and upgrading the memory to 8 GB.

I use this machine every day. It is my daily driver. I have no real plans to replace it unless I find a deal I can't pass up. The machine works great and is very responsive.

How can I get by with a computer this old? My daily workflow is terminal based. Mutt for mail, khal for calendar, todoman for tasks, khard for contacts, newsboat for RSS, mpv for video, mpd for music, and vim for editing.

Do I use terminal based programs because they save an old computer from the trash heap. The answer is no. I find that terminal programs can increase my productivity. I am faster in Vim than in LibreOffice, I am faster on the command line than many graphical file utilities. It is quicker to have Newsboat download my daily reading, viewing, and listening than surf the net with a graphical browser.

Does this mean I do not use graphical programs? No, the web is a graphical place so yes I use a graphical browser when I am surfing looking for something, I use LibreOffice when I am doing a complicated spreadsheet, and I use GNUcash for my bookkeeping. I am saying terminal programs when appropriate can increase the speed at which you can work.

Is there more of a learning curve? Sometimes, but not always. Graphical programs have a steep learning curve if we actually learn the program. Graphical programs do have one sweet spot. If you don't really know anything about the program and just want to do the absolute rudimentary things in the program you can do that out of the box. The problem is often we a content with that and never go beyond that. To actually to be proficient in a program that takes study whether it be terminal based or graphically based.

Zettelkasten ID dailydriver-2020-05-13-1304