How do I associate a file extension with an application using a .desktop file (under linux)?

心已入冬 提交于 2021-02-07 20:49:44

问题


I have a .desktop file which associates my application (mmxfer) with specific mime types, and this works fine. When I right click a media file it gives me the option to use mmxfer to open it.

But what if I want to associate a project with a specific file extension, say '.sply', which really just contains some data serialized from python and so doesn't have a unique mime-type?

My current .desktop file is below. What should I change to associate mmxfer with '.sply' files?

[Desktop Entry]
Name=MMXfer
Comment=Convert music and video and transfer it to a portable player using mtp
Exec=/usr/local/bin/mmxfer %U
Icon=/usr/local/share/mmxfer/mmxfer.png
Terminal=0
Type=Application
Categories=Application;AudioVideo;
MimeType=application/ogg;

I missed out most of the mime types as there were dozens.

Thanks!


回答1:


You need to create a MIME type first.




回答2:


I hope this previous post is helpful. Also take a look at XDG's Shared MIME info database.



来源:https://stackoverflow.com/questions/4218655/how-do-i-associate-a-file-extension-with-an-application-using-a-desktop-file-u

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!