I run Debian Jessie without a desktop environment (I use the tiling window manager i3) and like to use xdg-open to quickly open files using a preferred application. I have an ongoing problem setting the preferred app for PDF files though. This is my problem in a nutshell:
$ xdg-mime query filetype ~/Downloads/document.pdf application/pdf $ xdg-mime query default application/pdf /usr/share/applications/qpdfview.desktop $ xdg-open ~/Downloads/document.pdf [opens gimp!]
Any ideas would be hugely appreciated – this has been plaguing me for about a year. The only way I’ve ever managed to (temporarily) fix it is by directly editing the mimeinfo.cache and removing the reference to gimp from the application/pdf record.
And yes, /usr/share/applications/qpdfview.desktop exists and contains the correct location of the qpdfview binary. (Indeed, this .desktop file is used when I hand-edit mimeinfo.cache.)
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You could attempt to manually set it via the command line using mimeopen.
Example
$ mimeopen -d ~/test.pdf
Please choose a default application for files of type application/pdf
1) E-book Viewer (calibre-ebook-viewer)
2) Document Viewer (evince)
3) Xournal (xournal)
4) GNU Image Manipulation Program (gimp)
5) Xpdf PDF Viewer (xpdf)
6) Print Preview (evince-previewer)
7) Inkscape (inkscape)
8) calibre (calibre-gui)
9) Other...
use application #2
Opening "/home/saml/Downloads/test.pdf" with Document Viewer (application/pdf)
Which results in my PDF file, test.pdf opening up in Evince. From this point on Evince is the default when I use xdg-open.
References
- How to get a list of applications associated with a file using command line
- Is there an “open with” command for the command line?
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0