特殊:Badtitle/NS100:AddingMimeTypes:修订间差异
小 创建新页面为 '{{From|https://help.ubuntu.com/community/AddingMimeTypes}} {{Languages|UbuntuHelp:AddingMimeTypes}} === Introduction === MIME types are a sort of identification card for files o...' |
(没有差异)
|
2009年5月18日 (一) 14:57的版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/AddingMimeTypes }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/af | • {{#if: UbuntuHelp:AddingMimeTypes|Afrikaans| [[::AddingMimeTypes/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/ar | • {{#if: UbuntuHelp:AddingMimeTypes|العربية| [[::AddingMimeTypes/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/az | • {{#if: UbuntuHelp:AddingMimeTypes|azərbaycanca| [[::AddingMimeTypes/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/bcc | • {{#if: UbuntuHelp:AddingMimeTypes|جهلسری بلوچی| [[::AddingMimeTypes/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/bg | • {{#if: UbuntuHelp:AddingMimeTypes|български| [[::AddingMimeTypes/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/br | • {{#if: UbuntuHelp:AddingMimeTypes|brezhoneg| [[::AddingMimeTypes/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/ca | • {{#if: UbuntuHelp:AddingMimeTypes|català| [[::AddingMimeTypes/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/cs | • {{#if: UbuntuHelp:AddingMimeTypes|čeština| [[::AddingMimeTypes/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/de | • {{#if: UbuntuHelp:AddingMimeTypes|Deutsch| [[::AddingMimeTypes/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/el | • {{#if: UbuntuHelp:AddingMimeTypes|Ελληνικά| [[::AddingMimeTypes/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/es | • {{#if: UbuntuHelp:AddingMimeTypes|español| [[::AddingMimeTypes/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/fa | • {{#if: UbuntuHelp:AddingMimeTypes|فارسی| [[::AddingMimeTypes/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/fi | • {{#if: UbuntuHelp:AddingMimeTypes|suomi| [[::AddingMimeTypes/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/fr | • {{#if: UbuntuHelp:AddingMimeTypes|français| [[::AddingMimeTypes/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/gu | • {{#if: UbuntuHelp:AddingMimeTypes|ગુજરાતી| [[::AddingMimeTypes/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/he | • {{#if: UbuntuHelp:AddingMimeTypes|עברית| [[::AddingMimeTypes/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/hu | • {{#if: UbuntuHelp:AddingMimeTypes|magyar| [[::AddingMimeTypes/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/id | • {{#if: UbuntuHelp:AddingMimeTypes|Bahasa Indonesia| [[::AddingMimeTypes/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/it | • {{#if: UbuntuHelp:AddingMimeTypes|italiano| [[::AddingMimeTypes/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/ja | • {{#if: UbuntuHelp:AddingMimeTypes|日本語| [[::AddingMimeTypes/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/ko | • {{#if: UbuntuHelp:AddingMimeTypes|한국어| [[::AddingMimeTypes/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/ksh | • {{#if: UbuntuHelp:AddingMimeTypes|Ripoarisch| [[::AddingMimeTypes/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/mr | • {{#if: UbuntuHelp:AddingMimeTypes|मराठी| [[::AddingMimeTypes/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/ms | • {{#if: UbuntuHelp:AddingMimeTypes|Bahasa Melayu| [[::AddingMimeTypes/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/nl | • {{#if: UbuntuHelp:AddingMimeTypes|Nederlands| [[::AddingMimeTypes/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/no | • {{#if: UbuntuHelp:AddingMimeTypes|norsk| [[::AddingMimeTypes/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/oc | • {{#if: UbuntuHelp:AddingMimeTypes|occitan| [[::AddingMimeTypes/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/pl | • {{#if: UbuntuHelp:AddingMimeTypes|polski| [[::AddingMimeTypes/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/pt | • {{#if: UbuntuHelp:AddingMimeTypes|português| [[::AddingMimeTypes/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/ro | • {{#if: UbuntuHelp:AddingMimeTypes|română| [[::AddingMimeTypes/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/ru | • {{#if: UbuntuHelp:AddingMimeTypes|русский| [[::AddingMimeTypes/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/si | • {{#if: UbuntuHelp:AddingMimeTypes|සිංහල| [[::AddingMimeTypes/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/sq | • {{#if: UbuntuHelp:AddingMimeTypes|shqip| [[::AddingMimeTypes/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/sr | • {{#if: UbuntuHelp:AddingMimeTypes|српски / srpski| [[::AddingMimeTypes/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/sv | • {{#if: UbuntuHelp:AddingMimeTypes|svenska| [[::AddingMimeTypes/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/th | • {{#if: UbuntuHelp:AddingMimeTypes|ไทย| [[::AddingMimeTypes/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/tr | • {{#if: UbuntuHelp:AddingMimeTypes|Türkçe| [[::AddingMimeTypes/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/vi | • {{#if: UbuntuHelp:AddingMimeTypes|Tiếng Việt| [[::AddingMimeTypes/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/yue | • {{#if: UbuntuHelp:AddingMimeTypes|粵語| [[::AddingMimeTypes/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/zh | • {{#if: UbuntuHelp:AddingMimeTypes|中文| [[::AddingMimeTypes/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/zh-hans | • {{#if: UbuntuHelp:AddingMimeTypes|中文(简体)| [[::AddingMimeTypes/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:AddingMimeTypes | UbuntuHelp:AddingMimeTypes | {{#if: | :}}AddingMimeTypes}}/zh-hant | • {{#if: UbuntuHelp:AddingMimeTypes|中文(繁體)| [[::AddingMimeTypes/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:AddingMimeTypes|:AddingMimeTypes|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :AddingMimeTypes/zh | | {{#ifexist: AddingMimeTypes/zh | | {{#ifeq: {{#titleparts:AddingMimeTypes|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:AddingMimeTypes|1|-1|}} | zh | | }}
Introduction
MIME types are a sort of identification card for files on Ubuntu. A file's MIME type is usually determined by the extension of its filename; for example, a text file may end in .txt, and image file might end in .png or .jpg. This tells Ubuntu what icon should be used to represent it and what programs should open it by default. Unfortunately, the obvious options for editing MIME types in Ubuntu are shallow. You can teach Ubuntu to open a certain file extension with a certain program using the Properties window, but you cannot set an icon for that extension as a whole: only for the individual file. This can be annoying if you are say, a Python programmer. Ubuntu does not include a special icon for Python files, and it is hard to visually differentiate .py and .pyc files. This guide will both teach you to add new MIME types and to associate icons with existing types. We will use .py files as an example.
Adding a MIME Type
To start out, we must be assure that the MIME type for our file extension does not already exist. Open a command line and enter the line below, replacing the letters py with your extension.
grep 'py' /etc/mime.types
Analysing results
This particular command will output two lines. If your extension does not output any lines, or if the lines outputed do not include your extension, tyou must create a new MIME type. Otherwise, look at the right side of this output, find your file extension, and copy the corresponding text to the far right. For 'py', we must copy down 'text/x-python'.
application/x-python-code pyc pyo text/x-python py
Creating the MIME type, if needed
If there was no output, or the output given did not include your extension, we must add a MIME type.
gksudo gedit /etc/mime.types
Modify the following text so that the word "extension" is replaced with your file extension (no period mark), add the line to the end of the mime.types file, and save.
text/extension extension
And copy the modified 'text/extension' part.
Adding an Icon
Now we need to associate and icon with the MIME type. Get an SVG icon and name it "text/extension .svg", or whatever your modified MIME type is named; this will be the icon to represent all instances of the MIME type on your system. For our python example, this is a good choice. Rename the .svg file so that the it matches "text/x-python.svg" (or "insertYourMIMEtype.svg") so that the slashes are replaced with "-" and there are no capital letters. Then simply run the following command, with 'text/x-python' replaced with your MIME type.
sudo cp text-x-python.svg /usr/share/icons/gnome/scalable/mimetypes
Relogin and all files ending in the MIME extension will display with that icon.