在 Linux 中注册文件扩展名/MIME 类型 [英] Register file extensions / mime types in Linux
问题描述
我正在开发一个具有自己文件格式的 Linux 应用程序.我希望在您双击这些文件时打开我的应用.
I'm developing a Linux application that has its own file format. I want my app to open when you double-click on those files.
如何在 Linux 上注册文件扩展名并将其与我的应用程序相关联?我正在寻找一种标准方式(适用于基于 GNOME 和 KDE 的系统)并且可以在我的程序第一次安装或运行时自动完成.
How can I register a file extension and associate it with my application on Linux? I'm looking for a way that is standard (works with GNOME and KDE based systems) and can be done automatic when my program is installed or run for the first time.
推荐答案
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.
这篇关于在 Linux 中注册文件扩展名/MIME 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!