Ubuntu – What does ā€œ%Uā€ mean when calling a command

command line

When editing the Applications menu, I see for some applications their commands have %U such as gedit %U and gnome-mplayer %U, but others don't such as gcalctool.

I was wondering what %U means when calling a command, and when it is needed and when it is not? Thanks!

This is motivated from my previous question, where I followed a reply but did not make it work.

Best Answer

It's 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.

So, e.g., /usr/share/applications/gedit.desktop contains:

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.