XDG-Open Command – How It Determines Which Application to Use

xdg-open

I would expect xdg-open command to use the same application that opens when I double-click the file in the default file manager, but this is not always true.

For example my DE is XFCE, my file manager is Thunar and my default picture viewer is Ristretto. However, xdg-open example.png opens the example PNG file in Pinta. Why?

Best Answer

xdg-open is a desktop-independent tool for configuring the default applications of a user. Many applications invoke the xdg-open command internally. Inside a desktop environment (like GNOME, KDE, or Xfce), xdg-open simply passes the arguments to those desktop environment's file-opener application (eg. gvfs-open, kde-open, or exo-open). which means that the associations are left up to the desktop environment. When no desktop environment is detected (for example when one runs a standalone window manager like eg. Openbox), xdg-open will use its own configuration files.

from archwiki

specific to your question, you could try this to set the default application associated with the png file:

xdg-mime default <ristretto.desktop> image/png

you need find out what exactly the desktop file name of Ristretto. afterwards, you could check it with this:

xdg-mime query default image/png
Related Question