xdg-open is a desktop-independent tool for configuring the default applications of a user. Many applications invoke the Template:Codeline command internally.
Inside a desktop environment (e.g. GNOME, KDE, Xfce, etc.),
xdg-open simply passes the arguments to that desktop environment's file-opener application (
exo-open, respectively), 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, e.g. Openbox),
xdg-open will use its own configuration files.
xdg-open is part of thepackage available in extra:
pacman -S xdg-utils
xdg-open is for use inside a desktop session only. It is not recommended to use xdg-open as root.
The config file
xdg-open use configuration files located at
~/.local/share/applications/defaults.list(for a single user) and
/usr/share/applications/defaults.list (system wide). Its format is as follows:
[Default Applications] mimetype=desktopfile1;desktopfile2...
[Default Applications] text/html=firefox.desktop inode/directory=kde4-dolphin.desktop;Thunar.desktop;nautilus.desktop
The best way to look up the MIME type is to read the
MimeTypes list in your application's
Some tools are available to edit the configuration files:
To make Thunar the default file-browser, i.e. the default application for opening folders.
xdg-mime default Thunar.desktop inode/directory
to useas the default PDF viewer:
$ xdg-mime default xpdf.desktop application/pdf
This should create an entry in your local MIME database:
[Default Applications] application/pdf=xpdf.desktop
Your PDF files should be opened withnow.
mimetype inpackage is more intuitive.
To select default application for a given extension (you need a sample file):
$ mimetype -d file.extension
AUR provide and contains a
xdg-open script patched to make use of
mimeo the same way
gnome-open would be used. Mimetype<->application associations can then be customised easily in
This variable set default application for URLs. For example, when using Openbox without a desktop environment, do the following:
will make xdg-open use chromium for any kind of URLs
When this variable is set, xdg-open will use the more user-friendly file-opener application that desktop environment provides. Some packages need to be installed to use this feature. For GNOME, that would be. For Xfce, 'exo'.
$DE environment variable needs to be exported before starting the window manager. For example:
export DE="xfce" exec ck-launch-session openbox
This will make xdg-open use the more user-friendly exo-open, because it assumes it is inside Xfce. Use exo-preferred-applications for configuring.
For LXDE desktop enviroment users modify
Then xdg-open will use pcmanfm file associations.