Setting a Default application

I’ve installed both xpdf and mupdf. I want mupdf to be my default PDF viewer. However no matter what I do, xpdf keeps on launching for pdf files. How do I change this behaviour? TIA ....
 
The answer you seek depends on what you are using to invoke the PDF viewer. You need to find out how it is configured to behave.

As Trihexagonal suggests, if your are running the xfe(1) file manager, then Edit->Preferences->Programs.

fluxbox(1) is window manager, not a file manager.

I'm not familiar with fluxbox(1), but xdg-mime(1) from devel/xdg-utils may be a good place to start, as it is designed to "integrate with the free desktop".

Lastly, just to obfuscate a little, the historical (probably now ancient) way of specifying the default application to invoke for any given file type (as identified by the "magic number", and as used by file(1)) was to use mailcap(4). Some of the more recent mechanisms will defer to metamail(1) if it's available.
 
xdg has xdg-mime as an application.

# xdg-mime query default application/pdf
xpdf.desktop

So you might need to create the xpdf.desktop file and make sure xpdf is set as default with xdg-mime.
/usr/local/share/applications/xpdf.desktop
Code:
[Desktop Entry]
Name=xpdf
GenericName=PDF viewer
Comment=Display PDF files
Exec=xpdf %f
Icon=xpdf
Terminal=false
Type=Application
MimeType=application/pdf;
Categories=Viewer;Graphics;
Keywords=Viewer;Graphics;

 
Ok, I just tested. I actually have xpdf set as default for chromium and I didn't want that, I wanted zathura. First, to answer my own question, I changed $HOME/.config/mimeapps.list to use zathura.desktop instead of xpdf.desktop.
I then went to /usr/local/share/applcations and copied xpdf.desktop to zathura.desktop, substituting zathura for xpdf where it occurred in the file. I then went to open a pdf in chromium and it used zathura. To test for the OP, i also tried with mupdf and it works.

So, to sum up.
Edit your $HOME/.config/mimeapps.list so that the application for pdf says mupdf.desktop instead of xpdf.desktop. Go to /usr/local/share/appplications/ and copy the xpdf.desktop file to mupdf.desktop. In that new mupdf.desktop file, anywhere that you see xpdf, change it to mupdf. You shouldn't have to restart anything for it to work. I don't have icons--I use either dwm or openbox. If you use a desktop that uses icons, I don't know what you would edit to change the desktop icon, but hopefully, it's not overly complicated.
 
You guys give me headaches, why no deinstall the one pdf viewer you don't want, this way the other one will be the default.
 
It's a fair question. In my case, I prefer different pdf readers for different situations and I'm not overly worried about resources or disk space. As an example, I don't think you can print from mupdf, whereas you can from xpdf. Yet for general use I might prefer mupdf.
 
pkg install mupdf will not add a mupdf.desktop to /usr/local/share/applications directory. After the creation of mupdf.desktop, run xdg-mime default mupdf.desktop application/pdf . Check man xdg-mime default command.
 
Back
Top