Bloggings

Back

Lynx, Gopher, and video files

2025-09-21

Getting Lynx to open video files

I've been using Lynx as a Gopher browser on Artix Linux, and I like it a lot as it renders cleanly, has logical keybindings, and enables following html links.

But...

Trying to open video files with an external application wasn't working. Luckily on one test I saw an error concerning "mpeg_play".

The only mention of this file is as a VIEWER entry in lynx.cfg. But changing it to something else has no effect at all.

Somewhere in lynx, mpeg_play is hardcoded. 🤔. Checking the Lynx source code, I found it in HTInit.c

Why short circuit the config file this way? Anyway, I wrote a bash script named mpeg_play:

#!/usr/bin/env bash
/usr/bin/mpv --title="Mpv" >/dev/null 2>&1 $1

chmod +x mpeg_play and put it in my PATH

and it works!
Lynx can now play media files in Gopher holes. (Note the --title parameter is to get it to play nice with dwm).

The question remains: why is this hard coded?

As for mpeg_play, it appears in Linux mailcap entries in the 90's and seems to have been bundled in ximagetools.

Mpeg_play appears to date back a long way as a UNIX application:

http://www.geom.uiuc.edu/software/mpeg_play

Update 2025-09-23

A little tweak made this script capable of opening playlists

----------

#!/usr/bin/env bash
# necessary for Lynx browser video files
# chmod +x and place in your PATH

# mpv can sometimes take a few seconds to open when streaming
# so I use notification that it's happening

dunstify -t 2000 -a "Video" -u low -i "media-playback-start-symbolic"\
  -h string:x-dunst-stack-tag:"Media" "MPV Launching" &

# detect if playlist
# Lynx uses an anonymous file in /tmp, so we can only
# detect a file type by it's contents, not it's extension

if [ "$(grep -c "EXT3MU" "$1")" -eq 1 ]; then
  # this is a playlist
  # I use dwm, the mpv options used here make it compatible
  mpv --geometry=1068x600 --ontop --idle=yes --force-window=yes\
    --playlist="$1" >/dev/null 2>&1 &
else
  mpv --geometry=1068x600 --ontop --idle=yes --force-window=yes\
    "$1" >/dev/null 2>&1 &
fi

exit 0

----------

The latest version can be found at git.wittamore.fr