Skip to content

Linux desktop files

Location of .desktop files

directory purpose
/usr/share/applications/ default Linux distro specific applications
/usr/local/share/applications/ Third party specific applications
~/.local/share/applications/ User specific applications

some are stored in the app directory , but that is not the goal

count .desktop files using the wc command

ls -l /usr/share/applications/ | wc -l

to install and edit desktop files on Linux (Desktop entries)

First, validate your desktop entries using the desktop-file-validate command. For example:
desktop-file-validate ~/desktop-entries/gpass.desktop
Then install the file using the desktop-file-install command, run:
desktop-file-install --dir=~/.local/share/applications ~/desktop-entries/gpass.desktop
Finally, update the database, run:
update-desktop-database ~/.local/share/applications

zie https://www.cyberciti.biz/howto/how-to-install-and-edit-desktop-files-on-linux-desktop-entries/ { #_IN_ZOTERO }

%u is a parameter for the Exec key in .desktop files (defined in the Desktop Entry Specification) that describes how arguments to the program (from the file manager/program launcher, e.g. multiple selected files) should be handled:
%u A single URL. Local files may either be passed as file: URLs or as file path.
%U A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path.
Exec=gedit %U
which means that arguments to gedit will be treated as a list of URLs (or local files).
For a complete list of possible parameters, see The Exec key – http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html

Only command line options with one hyphen are possible in the Exec field:
gourmet --gourmet-directory $HOME/my/custom/path/
nok :
Exec=gourmet --gourmet-directory $HOME/my/custom/path/
ok :
Exec=gourmet --gourmet-directory /ward/home/my/custom/path/
Exec=sh -c "gourmet --gourmet-directory $HOME/my/custom/path/ "

using %F  : should the application open a list of files

open desktop files from the terminal with arbitrary arguments is not how .desktop files are used.

Only certain variables are allowed in the arguments, essentially corresponding to desktop-like actions: files to open, and so forth.
do it using codes like %f for a file, and then using the UI to drag a file onto the application, for example.
Another way to configure an application is to use Desktop Actions, which essentially are an enumerated list of ways to open an application.
So if you have a well-defined set of arguments you want to use, that would work.

See the Desktop Entry specification for details on the argument codes and how desktop actions work.