Find the default application for a certain extension

xdg-open

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 xdg-open and .jpg the result is eog.

Best Answer

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>

See man xdg-mime for further usage information.

Related Question