Sunday, October 27, 2013

Configuring xdg-open

Open/Libre-office spreadsheet hyperlinks would not open PDF files with Acroread even though caja was properly set to do so by default.
 

Xdg-open is the freedesktop.org scheme for opening files and URLs with our preferred applications.

First I verified that PDF files were recognized as such:

> xdg-mime query filetype somepdffile.pdf 
application/pdf
Good, and then that Acroread was the default application:
> xdg-mime query default application/pdf
userapp-acroread-9UNI5W.desktop
Excellent, but does it work?
> xdg-open somepdffile.pdf
Error: no "view" mailcap rules found for type "application/pdf"
Opening "somepdffile.pdf" with Document Viewer  (application/pdf)
In this case "Document Viewer"is Atril, not Acroread.

Poking around the mailcap thing I edited the user section in /etc/mailcap as so:

#  User section follows:  Any entries included in this section will take
#  precedence over those created by "update-mime".  DO NOT CHANGE the
#  "User Section Begins" and "User Section Ends" lines, or anything outside
#  of this section!
#

# ----- User Section Begins ----- #
application/pdf;/usr/local/bin/acroread %s; test=test "$DISPLAY" != ""; description=Portable Document Format; nametemplate=%s.pdf; priority=1
# -----  User Section Ends  ----- #
That did the trick.







No comments:

Post a Comment