Petr Kovarpknbe@volny.czAdd a custom MIME type for all users
To add a custom MIME type for all users on the system and register a default
application for that MIME type, you need to create a new MIME type
specification file in the /usr/share/mime/packages/
directory and a .desktop file in the
/usr/share/applications/ directory.
Add a custom application/x-newtype
MIME Type for All Users
Create the /usr/share/mime/packages/application-x-newtype.xml
file:
new mime type]]>
The sample application-x-newtype.xml file above
defines a new MIME type application/x-newtype
and assigns file names with the .xyz extension to
that MIME type.
Create a new .desktop file named, for example,
myapplication1.desktop, and place it in the
/usr/share/applications/ directory:
The sample myapplication1.desktop file above
associates the application/x-newtype MIME type
with an application named My Application 1,
which is run by a command myapplication1.
As root, update the MIME database for your changes to take effect:
update-mime-database /usr/share/mime
As root, update the application database:
update-desktop-database /usr/share/applications
To verify that you have successfully associated
*.xyz files with the
application/x-newtype MIME type, first create
an empty file, for example test.xyz:
touch test.xyz
Then run the gio info command:
gio info test.xyz | grep "standard::content-type"
standard::content-type: application/x-newtype
To verify that myapplication1.desktop has been
correctly set as the default registered application for the
application/x-newtype MIME type, run the
gio mime command: