Can someone provide example on how to use (with GNOME Ubuntu) the XDG-MIME command? I'm struggling to get anything working even with the docs.
For example if I want to register the extension .mfe with an application called MyApp what would the steps be? This is my attempt so far, I would appreciate any pointers on getting this right...
This is my xml (MyApp-MyFileType.xml) How is the file name relavent?
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/mfe">
<comment>File for MyApp</comment>
<glob pattern="*.mfe"/>
</mime-type>
</mime-info>
Then is run this command?
xdg-mime install MyApp-MyFileType.xml
And then I run this? What does the xxx relate to?, I understand it to be an identifier to my application but how do I define it?
xdg-mime default xxx.desktop text/mfe
All the needed information is in man xdg-mime
.
Check the actual mime-type with xdg-mime query filetype filename.ext
(the response could be e.g. application/octet-stream
)
If you decide to create your own mime-type you should edit an XML file like the example you gave. You should check if the mime-type name you want to create exists to not override it. You can see the registered mime-types in /usr/share/applications/defaults.list
.
Then, as you pointed out, it's time to register the new mime-type with sudo xdg-mime install --mode system MyApp-MyFileType.xml
to install for all users on the system.
At this point, if you check again the mime-type (like in step 1.) you should have the desired response (your new mime-type).
Now it's time to register the new mime-type with the desired application. The association is done with sudo xdg-mime default MyApp.desktop text/mfe
(in your example). To see the available .desktop
files just do: ls /usr/share/applications | less
(I think this is what you were looking for).
The last step is registering the icon with xdg-icon-resource
but that's another topic.
Hope this helps!