Legg til ein tilpassa MIME-type for enkeltbrukarar
For å leggje til ein tilpassa MIME-type for enkeltbrukarar og registrere ein standardapp for han, må du lage ei ny MIME-typespesifikasjonsfil i mappa ~/.local/share/mime/packages/ og ei .desktop-fil i mappa ~/.local/share/applications/.
Legg til ein tilpassa MIME-type application/x-newtype for enkeltbrukarar
-
Opprett fila ~/.local/share/mime/packages/application-x-newtype.xml:
<?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>ny MIME-type</comment> <glob pattern="*.xyz"/> </mime-type> </mime-info>Dømefila application-x-newtype.xml ovanfor definerer den nye MIME-typen application/x-newtype og knyter filnamn med etternamnet .xyz til denne MIME-typen.
-
Opprett ei ny .desktop-fil, til dømes med namnet myapplication1.desktop, og legg ho i mappa ~/.local/share/applications/:
[Desktop Entry] Type=Application MimeType=application/x-newtype Name=My Application 1 Exec=myapplication1Dømefila myapplication1.desktop ovanfor knyter MIME-typen application/x-newtype til ein app som heiter My Application 1, og som vert køyrd med kommandoen myapplication1.
-
Oppdater MIME-databasen, så endringane dine får verknad:
$ update-mime-database ~/.local/share/mime -
Oppdater appdatabasen:
$ update-desktop-database ~/.local/share/applications -
For å stadfeste at du har knytt *.xyz-filer til MIME-typen application/x-newtype, lagar du først ei tom fil, til dømes test.xyz:
$ touch test.xyzKøyr deretter kommandoen gio info:
$ gio info test.xyz | grep "standard::content-type" standard::content-type: application/x-newtype -
For å stadfeste at myapplication1.desktop er rett sett som standardapp for MIME-typen application/x-newtype, køyrer du kommandoen gio mime:
$ gio mime application/x-newtype Standard program for «application/x-newtype»: myapplication1.desktop Registrerte program: myapplication1.desktop Tilrådde program: myapplication1.desktop