Default Applications in Linux
When you use xdg-open
(et al.), or click on a (e.g., PDF) file in a file manager, the system needs to know which application to use.
xdg (Cross Desktop Group) standardizes certain aspects of the desktop experience, making it easier for applications and desktop environments to work together across different Linux distributions and desktop systems. For setting default applications, we need 2 parts from the xdg
standard:
-
A
.desktop
file for the program we want to execute on a certain file type..desktop
files are a standard for applications to integrate into, e.g. applications menus of desktop environments. You probably find the .desktop file of your installed program in/usr/share/applications/
or in one of these locations. For instance, theorg.pwmt.zathura.desktop
looks like this:[Desktop Entry] Version=1.0 Type=Application Name=Zathura Comment=A minimalistic document viewer Exec=zathura %U Icon=org.pwmt.zathura Terminal=false Categories=Viewer; Keywords=PDF;PS;PostScript;DjVU;document;presentation;viewer;
mimeapps.list
file: Maps a MIME type to an application. You probably want to edit it in~/.config/mimeapps.list
, but there are other locations as well. Under the[Default Applications]
section, you can add additional entries, e.g.,application/pdf=org.pwmt.zathura.desktop
.
That’s it! You should now be able to use launcher such as xdg-open
on PDF files, and they should be opened in zathura.