How to open a file with drag to application?

Solution 1:

I don't know what file types GPSprune handles and which, specifically, you are interested in. So for the sake of simplicity let's just say you want to open files with the .foo extension in GPSprune. These files however are recognized as text files or XML files rather than GPSprune specific files. What you will have to do then is to first define a new MIME type that is specific to these files.

To do so you can either use assoGiate, a GUI file type editor, or manually define the new MIME type. In this tutorial I will show how to do this manually.

Create a new text file called foo.xml and open it up in your favorite text editor.

Copy and paste the contents of the following text box:

<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 <mime-type type="application/foo">
  <glob pattern="*.foo"/>
  <comment>GPSprune GPS dump</comment>
  <comment xml:lang="en">GPSprune GPS dump</comment>
 </mime-type>
</mime-info>

Make sure to replace all instances of .foo with the actual extension and edit the comment/description to your wishes.

Next save the file and move it to ~/.local/share/mime/packages. Update the mime database by typing in a terminal:

update-mime-database ~/.local/share/mime

Your .foo files are now recognized as a separate MIME entity. You can check whether everything worked by right clicking on a .foo file of your choice and looking at the file type listed under Properties.

Let's add an association to GPSprune now:

Open ~/.local/share/applications/mimeapps.list in an editor of your choice. Search for the [Default Applications] entry or create it if it doesn't exist yet. Then add the following line under default applications:

[Default Applications]
application/foo=gpsprune.desktop

You should now be able to immediately open up your .foo files with GPSprune and likely also to drag and drop them on the respective launcher.


Sources and related Q&As:

Add custom command in the open with dialog?

How can I deal with file association in different application(not in Nautilus)?

How to associate file extension (not file type) for a particular application?

https://ubuntugenius.wordpress.com/2009/11/19/create-your-own-file-types-in-ubuntu-with-assogiate/