Tuesday, March 11, 2014

Part 2: Specify default applications for file types - file managers

Part 1 introduced the xdg-mime command to change the default application for a file type. If you want a GUI method, or more tweaking is required after running the command, this post is for you.

File managers can create file associations - the assigning of a default application to open files of a certain extension. Below is an example of changing the PDF default application using the Nautilus file manager for the GNOME desktop.

  1. Open Nautilus, and navigate to any PDF file.
  2. Right click on the PDF file, and select Properties.
  3. Click to open the Open With tab.

    Note that this screen identifies the current Default Application -Document Viewer, an alias for evince.

  4. Select the new default application.

    If you find the application you want under Recommended Applications, click the app and then the Set as default button. Otherwise, click the Show other applications button to display more application choices.


If the application you want, say xpdf, is not listed under Recommended or Other applications, first make sure that it is installed.

If the application is installed, but not listed in the Open with tab,

  1. Edit the application's desktop file - xpdf.desktop.

    The desktop file can exist in 1 or both of the following locations.

    • $HOME/.local/share/applications/xpdf.desktop
    • /usr/share/applications/xpdf.desktop
  2. Append %U to the end of the Exec= line.

    The Exec= line specifies the command and any arguments to start the application. If the Exec= line does not specify that the application can take command line arguments, the application is omitted from the Recommended applications and Other applications lists.

    The Exec= line in the xpdf.desktop file should look like the following:

    Exec=xpdf %U

    %U indicates that the xpdf command can take multiple URLs as arguments.

xpdf should now appear in the Recommended applications list.

No comments: