All we need is an easy explanation of the problem, so here it is.
Given xdg-open and an extension, is there a way to get the application which xdg-open is set to for that particular extension?
For example given
.jpg the result is
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
AFAIK the choice of action is based on the file’s mimetype rather than its extension.
At least on Ubuntu, you should be able to use the
query action of
xdg-mime to show the default application for a specific mimetype
$ xdg-mime query default image/jpeg eog.desktop
You can check the mimetype for a particular file using
xdg-mime query filetype e.g.
$ xdg-mime query filetype kqDRdnW.jpg image/jpeg
or using the
file command e.g.
file --mime-type <file>
man xdg-mime for further usage information.
To query the mime type used by an existing file by using
xdg-utils, it works as:
$ xdg-mime query filetype yourfile.xxx
You can also set a new default, for instance to change an associated desktop entry by setting Thunar – a modern file manager for the Xfce Desktop Environment – as the default file browser you should enter:
$ xdg-mime default Thunar.desktop inode/directory
Or for example to set the default application for
http(s):// internet protocols, you can use:
$ xdg-mime default midori.desktop x-scheme-handler/http OR $ xdg-mime default midori.desktop x-scheme-handler/https
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂