I know I can write a .desktop file in /usr/share/applications or ~/.local/share/applications, but can I add new folders to the search path similar to the $PATH environment variable?

For example, I want to put my .desktop files in ~/mydesktop/ and make them available to the open-with dialog in Dolphin or Nautilus.


You need to create a directory called applications, put your .desktop files in there, and then add the path of the parent directory of applications (not including the applications directory itself!) to the XDG_DATA_DIRS environment variable. Once you do that, your files will be picked up.

It is important to note that the path needs to be added to this variable before your desktop manager is started. How this is accomplished will vary by distro and/or login manager. See also this answer on the subject.

The documentation for on the XDG_DATA_DIRS variable can be found here: https://standards.freedesktop.org/menu-spec/latest/ar01s02.html

This directory contains a .desktop file for each possible menu item. Each directory in the $XDG_DATA_DIRS search path should be used (i.e. desktop entries are collected from all of them, not just the first one that exists). When two desktop entries have the same name, the one appearing earlier in the path is used.

The element in a menu file indicates that this default list of desktop entry locations should be scanned at that point. If a menu file does not contain , then these locations are not scanned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.