Petr Kovar
pknbe@volny.cz 2014
Maak een aangepaste MIME-typespecificatie aan voor een specifieke gebruiker en stel een standaardtoepassing in.
Nathan Follens
nfollens@gnome.org 2022.

# Een aangepast MIME-type toevoegen voor specifieke gebruikers

To add a custom MIME type for individual users and register a default application for that MIME type, you need to create a new MIME type specification file in the ~/.local/share/mime/packages/ directory and a .desktop file in the ~/.local/share/applications/ directory.

# Add a custom `application/x-newtype` MIME type for individual users

Maak het bestand ~/.local/share/mime/packages/application-x-newtype.xml aan:

<?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-type type="application/x-newtype"> <comment>new mime type</comment> <glob pattern="*.xyz"/> </mime-type> </mime-info>

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 ~/.local/share/applications/ directory:

[Desktop Entry] Type=Application MimeType=application/x-newtype Name=My Application 1 Exec=myapplication1

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.

Werk de MIME-database bij om uw wijzigingen door te voeren:

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

Werk de toepassingsdatabase bij:

    $ update-desktop-database ~/.local/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

Voer dan de opdracht gio info uit:

    $ 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:

    $ gio mime application/x-newtype
    Default application for “application/x-newtype”: myapplication1.desktop
    Registered applications:
    	myapplication1.desktop
    Recommended applications:
    	myapplication1.desktop