I know about
xdg-mime which can query the mapping from MIME filetype to associated desktop application. But this can return mappings to non-existent applications, e.g.
$ xdg-mime default non-existent.desktop x-scheme-handler/http $ xdg-mime query default x-scheme-handler/http non-existent.desktop
How can I programmatically determine whether a given desktop application is valid, i.e. installed? I'm guessing that this would require searching both
$XDG_DATA_HOME and the paths in
$XDG_DATA_DIRS, but it seems that there should be some kind of utility for querying this application database, rather than having to do it manually.
AFAICS, many of the
xdg-* utilities are shell scripts containing a function
desktop_file_to_binary which provides something very close to what I want, but I can't see any way of accessing this function directly via those utilities. Of course, I could copy it into my own script, but that obviously sucks, because it's an unofficial solution which violates the privacy of the implementation.