且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Linux 中注册文件扩展名/MIME 类型

更新时间:2022-11-27 09:41:45

Use xdg-utils from freedesktop.org 波特兰.

Use xdg-utils from freedesktop.org Portland.

注册 MIME 类型的图标:

Register the icon for the MIME type:

xdg-icon-resource install --context mimetypes --size 48 myicon-file-type.png x-application-mytype

创建配置文件(freedesktop 共享 MIME 文档):

<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="application/x-mytype">
    <comment>A witty comment</comment>
    <comment xml:lang="it">Uno Commento</comment>
    <glob pattern="*.myapp"/>
  </mime-type>
</mime-info>

安装配置文件:

xdg-mime install mytype-mime.xml

这可以识别您的文件并与图标相关联.xdg-mime 默认 可以用于在您获得 后将应用程序与 MIME 类型相关联.desktop 文件已安装.

This gets your files recognized and associated with an icon. xdg-mime default can be used for associating an application with the MIME type after you get a .desktop file installed.