I would like know the full steps to create and register a new custom mime type on my system. If it matters, I am running KDE on Arch Linux.
The steps should include writing the XML file and associating an icon with the file type and anything else I need to do. I prefer to use xdg-mime
command line utilities only.
I wish to understand both adding this mime association for 1) my user account as well as 2) system-wide.
For the example, let's say I want to open certificate files with a custom application I will call MyCertInspector. I believe the XML should look similar to this:
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/publickey">
<glob-deleteall/>
<glob pattern="*.crt"/>
<glob pattern="*.cert"/>
</mime-type>
</mime-info>
As I understand it, when including glob-deleteall
in a user-local definition, it removes any existing system-wide mime associations. I would like to confirm that my understanding is correct.
I also understand that the first step in this process is to check for the existence of a mime-type with the file extension I plan to use. I'm not sure exactly how to do that on Arch because there is no /usr/share/applications/defaults.list on Arch and (at least on my system) there is no system-wide mimeapps.list
file.
For the answer, I am hoping for a step by step guide that covers every needed step and that mentions the specific directories where things should be located on an Arch Linux system.
From my research so far, I believe the general steps are:
- check for the existence of a mime-type with the file extension I plan to use
- create an XML file for my desired mime-type.
- register my XML file using
sudo xdg-mime install [options]
(and we should address both system mode and local user mode. - associate the new mime-type with the application(s) used to open it.
- register the icon for the mime-type.
- anything else (such as checks & verification steps a person should do)
My goal is that anyone who reads the answer to this question will be able to master all the complete process of creating and installing a custom mime-type on their system.
Best Answer
I will start by quoting the EXAMPLES section in
man xdg-mime
From the same
man
pageYes, glob-deleteall is used to overwrite the glob part of a mimetype definition but not only system-wide. Both depending on the mode
system mode would install to
/usr/share/mime/
. user mode to.local/share/mime
and the file list is:After all, run
to activate the configuartion.