Petr Kovar
pknbe@volny.cz 2014
Create a MIME type specification and register a default application.
Andika Triwidada
andika@gmail.com 2020-2023

# Add a custom MIME type for all users

Untuk menambahkan tipe MIME ubahan bagi semua pengguna di sistem dan mendaftarkan aplikasi baku untuk tipe MIME tersebut, Anda perlu membuat berkas spesifikasi tipe MIME baru di direktori /usr/share/mime/packages/ dan berkas .desktop di direktori /usr/share/applications/.

# Add a custom application/x-newtype MIME Type for All Users

Create the /usr/share/mime/packages/application-x-newtype.xml file:

<?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.

Buat sebuah berkas .desktop baru bernama, misalnya, myapplication1.desktop, dan tempatkan di direktori /usr/share/applications/:

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

Contoh berkas myapplication1.desktop di atas mengaitkan time MIME application/x-newtype dengan aplikasi bernama My Application 1, yang dijalankan oleh perintah 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

Untuk memverifikasi bahwa myapplication1.desktop telah ditetapkan dengan benar sebagai aplikasi terdaftar baku bagi tipe MIME application/x-newtype, jalankan perintah gio mime:

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