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
xdg-open opens a file or URL in the user's preferred application. If a URL is provided the URL will be opened in the user's preferred web browser. If a file is provided the file will be opened in the preferred application for files of that type. xdg-open supports file, ftp, http and https URLs.
xdg-utils is a set of tools that allows applications to easily integrate with the desktop environment of the user, regardless of the specific desktop environment that the user runs.
A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
The /usr/share/applications/mimeapps. list and /usr/share/applications/gnome-mimeapps. list files specify which application is registered to open specific MIME types by default. These files are provided by the distribution.
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!
To be able to xdg-open afile.myapp
:
xdg-mime install vendor-filetype.xml
myapp.desktop
file for your application, like this: .desktop example xdg-mime default myapp.desktop filetype
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With