MIME

来自百合仙子's Wiki
跳转到导航 跳转到搜索

GNOME 的设置

增加或修改一个类型

To add one or more MIME types for all users:

  1. Create or modify an existing Overrides.xml source XML file, containing the definitions for the MIME types. For more information, see Section 5.3 ― The source XML files.
  2. Place the Overrides.xml file in the /usr/share/mime/packages directory.
  3. Update the MIME database by running update-mime-database using the system account.
update-mime-database /usr/share/mime

To add one or more MIME types for a single user, follow the same steps, except place your Overrides.xml file in the ~/.local/share/mime/packages directory. 使用以下命令来更新数据库:

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

配置文件示例

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="application/x-maff-compressed">
    <sub-class-of type="application/zip"/>
    <glob pattern="*.maff"/>
    <comment>Mozilla Archive Format</comment>
  </mime-type>
  <mime-type type="application/x-vim-encrypted">
    <comment>Vim Encrypted File</comment>
    <comment xml:lang="zh">Vim加密文件</comment>
    <magic priority="50">
      <match value="VimCrypt~" type="string" offset="0"/>
    </magic>
  </mime-type>
</mime-info>

验证更改

使用 gnomevfs-info 来检查相应的文件。如果使用了 <magic> 来识别文件,则要加上 -s 参数。

为MIME类型指定应用程序

文件位置(主要部分):[1][2]

  • ~/.config/mimeapps.list
  • ~/.local/share/applications/mimeapps.list (旧)
  • /usr/share/applications/mimeapps.list

(以前也叫 defaults.list,只列默认应用程序。)

例子:

[Default Applications]
application/pdf=evince.desktop
text/html=epiphany.desktop
text/plain=gedit.desktop
image/jpeg=eog.desktop
image/png=eog.desktop
text/xml=gedit.desktop

图标

NautilusGNOME 应用使用的图标位于 ~/.local/share/icons 等地,在 .desktop 文件中指定。也在 /usr/share/mine 等目录的 iconsgeneric-icons 文件中有指定。

没有桌面环境下的文件打开

此时使用 gnome-open 依旧正常,但是使用 xdg-open 会将所有文件在浏览器中打开。指定 DE 环境变量可以让 xdg-open 使用指定的桌面环境下的工具来打开,如 DE=gnome 时可能会调用 gnome-open[3]

参见

外部链接

参考资料