104

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.

wjandrea
  • 14,504
Tim
  • 26,107

2 Answers2

108

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.

Salim B
  • 135
htorque
  • 66,086
2

Thanks for a really useful answer, still helpful 13 years on.

The %U may also be found within a Flatpak command line, as for example:

/usr/bin/flatpak run --command=calibre --file-forwarding com.calibre_ebook.calibre --detach @@u %U @@

The --file-forwarding option takes URIs within the @@u %U @@ phrase and passes these to the called program as individual URIs on the command line.

RAG
  • 21