Find the default application for a certain extension

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

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 Thunara 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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x