Linux – How to Find Application for a MIME Type

freedesktopmime-types

Is there a linux API that can find the default application for a MIME type? Then I can use this application to open a file.

I can not use xdg-open(url) because the file format is a wrapper format and shared mime-type can only tell the wrapper MIME type. The embedded mime type can only be got from the wrapper file header.

The process would be like: 1. find embedded mime type 2. mime-open(embedded mime type, url)

Is it possible?

Best Answer

The xdg-mime command is used to query or set file associations.

jinx:735 Z$ xdg-mime query default application/pdf  
evince.desktop
Related Question