Configuring file associations is easy if you’re using a full-featured desktop environment, such as KDE, Gnome or Xfce. In such case, xdg-open delegates the task of opening file to kde-open, gnome-open or exo-open, depending on the environment. But with Openbox and similar environments it’s not that easy.
It’s likely that when you click on a just downloaded PDF file, it opens in Firefox and not in Evince or Okular (or your any PDF-reader of choice), because xdg-open defaults to Firefox.
One possible solution is to install a part of KDE, Gnome or Xfce environment, and use one of the *-open family. But we’ll try a more “pure” solution.
Creating list of default applications
Let’s be lazy and instead of creating a huge list of possible mime-types, install gnome-defaults-list AUR package. After installation you’ll find a file:
Copy it to:
if you want it system-wide.
These are the default Gnome associations, so you may want to edit them. And, for example, to use Okular to open PDF files instead of Evince, change line:
It’s important that these .desktop files should exist and be placed in
KDE applications’ .desktop files are by default in /usr/share/applications/kde4/, and you may need to create symbolic links to /usr/share/applications/.
Make it better
Current configuration is often unsuccessful in guessing file’s mime-type. You can make it better by installing perl-file-mimeinfo:
pacman -S perl-file-mimeinfo
Set default browser
The default browser is still Firefox. If you use Firefox, leave it as it is. But if you’re using Chromium, or Opera, or any other, you need to set the BROWSER environment variable.
to your Openbox autostart file:
and restart Openbox.
Test the configuration
To determine whether the above changes worked as expected, try to open downloaded file in your browser, or try xdg-open in console.
should open Google’s webpage in your default browser, and
should open the file in your favourite PDF reader. It should also work for documents, images, movies, etc.