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.