Extensions de fichiers sous GNOME

De Cliss XXI
Sauter à la navigation Sauter à la recherche

(Tested with GNOME 2.14)

2 steps:

  • Map your extension with a MIME type
  • Map this MIME type to an application

The goal is to map .eml with a locally installed Thunderbird (~/software/thunderbird/thunderbird).

Map your extension with a MIME type

  • (needed?) Declare the MIME type in /etc/mime.types

ex:

application/local.mozilla.thunderbird		eml
  • Declare the MIME type in /usr/share/mime/packages/

ex: /usr/share/mime/packages/thunderbird.xml :

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
	<mime-type type="application/local.mozilla.thunderbird">
		<comment>Saved mail</comment>
		<comment xml:lang="fr">Courriel enregistré</comment>
		<glob pattern="*.eml"/>
	</mime-type>
</mime-info>
  • Refresh the mime cache:
update-mime-cache /usr/share/mime/


Map your MIME type to an application

  • You can right-click on a file with your extension, and select "Open with".
~/.local/share/applications/*.desktop
~/.local/share/applications/mimeinfo.cache
  • You can create a site-wide .desktop with 'NoDisplay=true' so it doesn't show in the Applications menu
/usr/local/share/applications/*.desktop
/usr/local/share/applications/mimeinfo.cache

or

/usr/share/applications/*.desktop
/usr/share/applications/mimeinfo.cache

Then update the cache with:

update-desktop-database

More: create a 'file'-like file detection. Currently the added MIME type conflicts with 'plain text'.


Files

/etc/mime.types                           # MIME declaration
/usr/share/mime/packages/*.xml            # glob
/usr/share/mime/application/*.xml         # cache?
/usr/share/mime/mime.cache                # cache
/usr/share/mime-info/*.mime               # ?
/usr/share/mime-info/*.keys               # ?
/usr/share/application-registry/*.applications # priority?
/usr/share/applications/*.desktop         # menu entry and App->MIMEs association
/usr/share/applications/mimeinfo.cache    # MIME->Apps association cache
/usr/share/applications/defaults.list     # priority override
/usr/local/share/applications/ # alternate hierarchy
~/.local/share/applications/   # alternate hierarchy

Priority precedence:

~/.local/share/applications/defaults.list
[Gnome hard-coded priorities, e.g. abiword.desktop - ugh >p]
/usr/local/share/applications/defaults.list
/usr/share/applications/defaults.list

Sample defaults.list:

[Default Applications]
application/msword=openoffice.org2.4-writer.desktop

Icons:

/usr/share/icons/*/*/mimetypes
ex: 
/usr/share/icons/hicolor/48x48/mimetypes/openofficeorg23-text.png

TODO

  • /usr/share/application-registry/*.applications

(for priority/precedence?)

  • Do we need to use these:
/usr/share/mime-info/*.mime
/usr/share/mime-info/*.keys


Avoid Abiword hard-coded high priorioty

dpkg-divert --rename \
 --divert /usr/share/applications/abiword-nothardcoded.desktop\
 /usr/share/applications/abiword.desktop
update-desktop-database

Links

  • Local overrides
    • /usr/share/applications/defaults.list
    • (?) /etc/gnome/defaults.list
    • ~/.local/share/applications/defaults.list