Image types (e.g. image/jpeg, image/png etc.) are widely supported by ImageMagick and Eye of GNOME, so the only way I see to set priority for EOG is to check it's supported formats in .desktop and list them in Default Applications section of mimeapps.list or to maintain a custom link with update-alternatives, but some formats could not be supported by one application and could by others.

Maybe there is a simpler way to handle application priorities for "unresolved" MIME types, supported by multiple applications?


1 Answer 1


The idea is that every GUI application should provide a .desktop file that describes which MIME types it will be able to handle.

With xdg-mime query default <MIME type>, you can find out the current default application for a particular MIME type. It returns the application ID, that is specified in the .desktop file of that application.

And with xdg-mime default <application id> <MIME type...> you can set a specific application as the default for one or more MIME types.

Setting the priority by MIME type makes more sense than setting it by application: for example, an image browser might be able to "open" a directory for producing a thumbnail view of all images within it, so it will have a inode/directory MIME type listed for it. But you might not usually want that image browser to become your primary tool for opening generic directories.

Some utilities might work on all files, like a tool that can be used to send files over Bluetooth. Such an utility would have the all/allfiles pseudo-MIME-type listed for it. If you could easily say "make this utility have priority for everything it can handle" without verifying what those types are first, it could have disastrous consequences if applied to such an utility.

If you are sure that all the MIME types of a specific program are appropriate to make primary, you can do this with:

APP_ID=$(basename "$1" .desktop)
xdg-mime default $APP_ID $(grep ^MimeType "$1" | cut -d = -f 2- | tr ';' ' ')

For example, if the application desktop file is /usr/share/applications/org.kde.gwenview.desktop (it is assumed the desktop file name includes the application ID), then you can start this script with name-of-script.sh /usr/share/applications/org.kde.gwenview.desktop and it will set that application to be the default for any MIME types it can handle, on the user account the script is run as.


You must log in to answer this question.