How to add a folder with .desktop files?

Solution 1:

According to GNOME Desktop System Administration Guide Customizing Menus : Desktop Entry Files

Desktop entry files must reside in the $XDG_DATA_DIRS/applications directory and must have a .desktop file extension. If $XDG_DATA_DIRS 1 is not set, then the default path is /usr/share is used. This also implies that user specific desktop entries may be located at $XDG_DATA_HOME/applications which is searched first. If $XDG_DATA_HOME is not set, then the default path ~/.local/share is used. Desktop entries are collected from all directories in the $XDG_DATA_DIRS environment variable. Directories which appear first in $XDG_DATA_DIRS are given precedence when there are several .desktop files with the same name.

1$XDG_DATA_DIRS is the environment variable defined in the XDG base directory specification.

So if $XDG_DATA_HOME does not say otherwise, you can place per-user .desktop files in ~/.local/share/applications. If you want a system-wide custom location, you should be able to add it to $XDG_DATA_DIRS ex.

XDG_DATA_DIRS=/opt:$XDG_DATA_DIRS

See also XDG Base Directory Specification

Solution 2:

You can use ~/.local/share/applications under your user's home folder to keep .desktop files that you want to have available for that user only.

Solution 3:

Not a fundamental answer to your actual question (i.e., how to add your custom directory to host .desktop launchers), but I suggest you could use /usr/local/share/applications for launchers of your self compiled applications that should be available system wide.

This directory is configured by default in Ubuntu in XDG_DATA_DIRS, and its purpose is exactly for what you are looking for, i.e., make your manually installed .desktop files available in the menu systems of any user.