4

I'm trying to make gpxviewer the default application to open .gpx files. The problem is that it doesn't appear in the "Open with" window neither I can add it. What I have tried:

  • Using Ubuntu Tweak as recommended here. It does not work for me because there is no "XML file" or "application/xml" option (.gpx files are recognized as XML files, which is correct).

  • Adding "MimeType=application/xml" to the GPXViewer launcher (stored in /usr/share/applications/gpxviewer.desktop). Still GPXViewer does not appear as an option to open this kind of files.

So how can I make this work?

1 Answer 1

5

Option 1 (Create new Mimetype)

You can try to create a new MimeType (application/gpx) for the gpx files.
Then you can set the gpxviewer as default application to open them.

For system wide

1) Add the new MimeType to the gpxviewer.desktop.

  • sudo nano /usr/share/applications/gpxviewer.desktop

Add the following line:

MimeType=application/gpx;

enter image description here

Save the changes in nano with Ctrl+O, Enter then Ctrl+X.

2) Create the new MimeType.

  • sudo nano /usr/share/mime/application/gpx.xml

Add the following to the gpx.xml file:

<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="application/gpx">
    <comment>GPX Files</comment>
    <generic-icon name="text-html"/>
    <glob pattern="*.gpx"/>
  </mime-type>
</mime-info>

Save the changes in nano with Ctrl+O, Enter then Ctrl+X.

NOTE: Please change the content of the file according to your needs.

3) Register the Mimetype.

  • sudo xdg-mime install --novendor --mode system /usr/share/mime/application/gpx.xml

4) Make the gpxviewer application as default to open gpx files.

  • sudo xdg-mime default gpxviewer.desktop application/gpx

5) To see the changes you can Logout & Login or run the following:

  • sudo -i

  • update-mime-database /usr/share/mime

Result:

enter image description here

enter image description here

enter image description here


Option 2 (Add gpxviewer to the list in application/xml)

For system wide

1) Add the "application/xml" MimeType to the gpxviewer.desktop.

  • sudo nano /usr/share/applications/gpxviewer.desktop

Add the following line:

MimeType=application/xml;

Save the changes in nano with Ctrl+O, Enter then Ctrl+X.

2) Update the database.

  • sudo -i
  • update-desktop-database

enter image description here

enter image description here

NOTE: To make gpxviewer default application to ope the MimeType application/xml ... just run:
xdg-mime default gpxviewer.desktop application/xml


Edit as per comment

AS Glutanimate says.. you can do this not for system wide, you can create the mimetype and add the default application for users like this Answer.

In the ~/.local/share/mime/packages directory, update with update-mime-database ~/.local/share/mime.

Add an association in the ~/.local/share/applications/mimeapps.list file,also you can copy/create a .desktop file into the ~/.local/share/applications/ directory.


Hope this helps.

5
  • Thanks for the very detailed answer. I used the first option and worked like a charm (but had to logout/login).
    – Salem
    Oct 16, 2013 at 13:01
  • @Salem..Glad to help, and yes, you are right for the first option you need the logout/login. I will edit the answer to add it. Thanks Oct 16, 2013 at 13:08
  • @RomanRaguet A logout/login isn't necessarily required, you can just update the mime database instead. Oct 17, 2013 at 5:17
  • @RomanRaguet Also, I would advise against modifying the system-wide launcher directly as it will reset on each update. It would probably be better to just add an entry to the user's ~/.local/share/applications/mimeapps.list. Oct 17, 2013 at 5:19
  • @Glutanimate...Thanks for your comments, I edited my answer. Please feel free to add more info. Oct 18, 2013 at 23:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .