Associating file extensions with separate programs for XML files.
Hello! I have two files that are both XML files, according to the properties tab. One is named one.tks, the other two.pvd. I've tried associating both files to different programs, but since they are both XML files changing the default program for one.tks will also change the default program for two.pvd. How do I associate the two different extensions (tks and pvd) with two separate programs?
Many thanks in advance! |
It depends entirely on your distro's desktop environment or file manager. Most file managers have a way of setting one default, then have another option for "open with" or something to that effect. You can't set 2 defaults.
|
I'm using Linux Mint 19 Cinnamon. So the filename extensions used here can not be associated with different programs, because their underlying filetype is the same? I was hoping their would be some backend fix.
|
Quote:
Linux does not, in general, pay any more attention to Microsoft style "file extensions" than it does to any other part of the file name, but it does pay attention to the file type as detected in the first few bytes of the content. If you understand and use that information, a kludge may be possible. |
I'm currently right clicking every file and specifying which program should open it. I know for instance that every file with the *.msh extension should be opened with GMSH, but Linux recognizes it to be a xml file type and opens it with gedit. I have loads more of such files that are clearly labelled through Microsoft style extensions.
Is there a similiar way to have a *.msh file automatically associate with a program? Can I introduce a new file-type xml/msh somewhere? Should I add a line that specifies which program to use in the file data? Many thanks |
They are not associated with extensions, they are associated as wpeckam stated via mime type. Perhaps the file manager in cinnamon has no way to "open with" - I have never used cinnamon so can't speak to the "Nemo" file manager. You could eliminate the file extensions entirely and the behavior would be the same.
|
Has anyone ever tries a method of adding a #! line to an xml file to force a particular program to load it by default?
I have never tried, but it seems a decent concept to research. |
Quote:
@OP. See xdg-mime(1). |
I think what you want is possible with mime types - they _can_ take file extensions into account.
I don't know exactly how, but look at e.g. ~/.config/mimeapps.list, ~/.local/share/applications/mimeinfo.cache, and the contents of ~/.local/share/mime. FWIW, I right-click files more often than double-click. |
Quote:
|
^ yeah I saw an XML file much like that in my ~/.local/share/mime. The glob pattern would be the key for the extension.
|
Thanks everyone! This helped a bunch.
I registered all extension that were unrecognised in my desktop environment to new Mime types using xdg-mime. I then coupled the new Mime types to existing programs using .desktop files. I'm marking this as solved. |
All times are GMT -5. The time now is 01:44 PM. |