logo

tested on openbsd 6.3

set default programs with xdg-mime(1)

when you click on a downloaded pdf file in firefox or when you run xdg-open(1), the file opens with ths default program for its mimetype.

check the mimetype with xdg-mime(1):

$ xdg-mime query filetype example.pdf
application/pdf
$

LET'S CHECK THE DEFAULT APPLICATION FOR APPLICATION/PDF?

$ xdg-mime query default application/pdf
gimp.desktop
$

what? why would you want to open your pdf files in gimp? weird. let's fix this.

first off, install mupdf, if you didn't yet.

# pkg_add mupdf
...
mupdf-1.11p2:glfw-3.2.1p0: ok
mupdf-1.11p2: ok
#

then create mupdf.desktop in ~/.local/share/applications directory with just two lines.

[Desktop Entry]
Exec=/usr/local/bin/mupdf %u

or use the full version:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=true
Exec=/usr/local/bin/mupdf %u
Name=MuPDF
Comment=A lightweight PDF viewer

set the new default application:

$ xdg-mime default mupdf.desktop application/pdf
$

let's verify:

$ xdg-mime query default application/pdf
mupdf.desktop
$

p.s. types for word and excel documents are not exactly what would you expect:

$ xdg-mime query filetype example.doc
application/octet-stream
$ xdg-mime query filetype example.xls
application/octet-stream
$ xdg-mime query filetype example.docx
application/zip
$ xdg-mime query filetype example.xlsx
application/zip
$