How can I get a list of applications that are capable to open a specific filetype / MIME-type? I'm searching for a desktop-environment independent solution on Linux.
I found the possibilty to get the MIME type for a file.:
~> xdg-mime query filetype test.svg
image/svg+xml
Then I could query for the default application for that MIME type.:
~> xdg-mime query default image/svg+xml
eog.desktop
Is there also a solution to get a list of programs (not default) that I can use for that file?
For example on a GNOME desktop, if I choose open with another application for *.json
file, I can see three (Atom, Gedit, Builder) applications that are recommended for opening the file.:
If I choose, show all applications, I can also see a further associated application (LibreOffice Writer).:
I found the file /home/user/.config/mimeapps.list
which has content like:
[Added Associations]
text/html=atom.desktop;firefox.desktop;midori.desktop;org.gnome.gedit.desktop;brackets.desktop;
application/javascript=atom.desktop;org.gnome.Builder.desktop;org.gnome.gedit.desktop;
and also has associated applications for a mime type, but I can not find a global mimeapps.list
file which is mentioned in the Arch Linux wiki.
Instead of writing your own script as suggested by @MirosławZalewski, consider using the perl-file-mimeinfo tool (ArchWiki link).
The
-d
option, long option--ask-default
, lets the user choose a new default program for given files.The
-n
option, long option--no-ask
, does not ask the user which program to use, it chooses the default program or the first program known to handle the file mimetype.In Fedora, this package is called perl-File-MimeInfo.
In Debian and Ubuntu, it is called libfile-mimeinfo-perl.