Replaces the piece of crap xdg-open. Written in TCL.
Depends on the Perl package File-MimeInfo, (on OpenBSD install with `pkg_add p5-File-MimeInfo`)
Config file ~/.config/opener/mime.conf has one mime type per line, in the form
`mimetype` `program to use`
e.g.
application/pdf mupdf
text/plain lite-xl
video/x-matroska mpv
Then configure your file manager to use it, eg:
Using nnn: `export NNN_OPENER=mime-opener.tcl` in .profile
Using lf: `map o &mime-opener.tcl $f` in .config/lf/lfrc
#!/usr/local/bin/tclsh8.6
set fil [open "~/.config/opener/mime.conf"]
set raw [read $fil]
close $fil
set theType [exec mimetype -b [lindex $argv 0]]
set mimeType [lsearch -index 0 $raw $theType]
set progWeWant [expr $mimeType + 1]
set namedProgWeWant [lindex $raw $progWeWant]
exec $namedProgWeWant "$argv" 0
© Brett Mahar
site nginx on openbsd