gpt4 book ai didi

linux - 如何在 Linux 中找到用于给定 MIME 类型的程序?

转载 作者:太空宇宙 更新时间:2023-11-04 11:42:11 24 4
gpt4 key购买 nike

我需要为给定的 MIME 类型打开查看器。如何在 Linux 中做到这一点。我想该方法特定于使用中的桌面环境。我想通过 C 程序来完成。

最佳答案

有一些 Gnome API 可以为您处理 mime 类型(在标题中声明,例如 <libgnomevfs/gnome-vfs-mime-handlers.h> ),但我认为了解幕后发生的事情也很有用。

有问题的函数本质上是读取、解析并向您呈现某些配置文件的内容,并且 here是对 Gnome 用来将 MIME 类型与文件相关联的文件的清晰解释,即:

extension .mime in the $gnome/share/mime-info directory or from the ~/.gnome/mime-info directory.

The file $gnome/share/mime-info/gnome.mime is special, as it contains the defaults for gnome, and is read first. In addition, the file ~/.gnome/mime-info/user.mime is read last.

如该 URL 的“默认键”部分所述,open 等键, view等是为您提供用于各种通用操作的命令(以及通过“标签”,也用于特定的命名操作)。

有关使用 API 的 C 代码示例,请参见例如this thread结束.

关于linux - 如何在 Linux 中找到用于给定 MIME 类型的程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1415427/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com