A detailed answer requires, of course, a detailed analysis of both the xdg specifications (concerning mime information in general and desktop files in particular), as well as various implementations of these standards.
and the short answer, in the style of “do this, and it will most likely work,” may sound like this: add a line connecting the desktop file of your program with the mime type you need to the file /usr/share/applications/defaults.list (some de seem to use in addition and /usr/share/applications/mimeapps.list ) .
example:
so that by default, when you open the file with the mime type image/png , the program described in the desktop /usr/share/applications/display-im6.desktop launched, add the following line to /usr/share/applications/defaults.list :
image/png=display-im6.desktop;
if the file did not exist before, it makes sense for the “beauty and correctness” to specify the section in the first line:
[Default Applications]
Of course, this behavior can be overridden by a similar user-defined file ~/.local/share/applications/defaults.list .
The system-wide binding of mime types to file suffixes is located in the /etc/mime.types file.
The system-wide cache for all bindings of registered desktop files to mime types is located in the /usr/share/applications/mimeinfo.cache file.
mimeopen -d .aviin Python" or "I want to know how to edit the program:~/.config/mimeapps.list" (see how xdg-mime is implemented or directly call this script ) or vice versa, say "I want to run.pyfiles" (then the answer is different: add shebang#!and callchmod +x). - jfsupdate-alternativesmechanism that allows you to choose which specific program is launched by specified names such aseditor,display,rename,java,nc, etc. There is not enough information in the question to understand whether it is applicable in your particular case. - jfs