Customize Lynx’s filetype behavior

configurationlynx

I love lynx. I love browsing without tabs. Call me a luddite, but I only use a modern browser if I have to. Which is about twice a day, for a few minutes at most.

There's one thing I really really hate about lynx, though. It's not immediately apparent how to customize lynx's behavior when it comes to filetypes.

If I encounter a .pdf file, it downloads it, then dutifully asks me if I'd like to save it to disk. Thanks, lynx. It's like you read my mind or something.

If I encounter a .torrent file, lynx downloads it, then opens it with transmission-gtk.

Uh… no, lynx. I would have either preferred transmission-cli or just having the torrent file.

If I try to open a magnet URL, lynx doesn't know what to do with it. (Psst! transmission-cli, lynx!

But the worst is when I download .ogg, because lynx assumes that I want to play it with VLC in the TTY using caca to render the video as ASCII.

Bad lynx!

How do I whip lynx into shape? How do I customize this behavior? Editing /etc/lynx/lynx.cfg does not seem to do the trick.

Best Answer

Lynx does the standard thing (unlike Firefox and Chrome) and uses the system's mailcap database. The system mailcap is in /etc/mailcap, and the per-user file is ~/.mailcap. Add entries like

application/x-bittorrent; transmission-cli '%s'; needsterminal
application/pdf; pdftotext '%s'; copiousoutput
application/ogg; vlc '%s'; test=test -n "$DISPLAY"
Related Question