Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
11  
Whoever just cast a downvote, do you mind explaining why you did this? –  Tim Mar 13 '11 at 19:48
1  
ignore the down vote - some (in my opinion, obnoxious) people go around casting down votes on questions and rarely answers that are valid and meaningful. Quite annoying, but there is nothing we can do about them, unless the site adds an update requiring a reason to down vote (I'll push for that :D). –  RolandiXor Mar 13 '11 at 23:02
    
@Roland: Thanks for the kind words! I was thinking what I had did irritated some people, but now it seems not my fault. –  Tim Mar 13 '11 at 23:16
    
no, no one was offended ^^ (as far as I would hope - or guess). Usually most down votes are valid, and backed up by a comment or - in my case, a reply on the chat, explaining why the down vote, but sometimes it's just someone who's bored :) –  RolandiXor Mar 13 '11 at 23:27

2 Answers 2

up vote 22 down vote accepted

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.

share|improve this answer
    
Thanks! (1) Could you give some examples? (2) When will none of these is specified? –  Tim Mar 13 '11 at 19:31
15  
The reason these parameter keys exist is so the desktop manager knows what to do if you open multiple selected objects at the same time or drop one or more objects on it. %U means the program can take all of them in a single invocation; %u means a separate invocation is needed for each object; if none of them are specified then the program doesn't know what to do with things dropped on it. There are other keys which allow the desktop manager to pass customization information to the program, and a separate set of selectors %f, %F, meaning it takes one/multiple files but not URLs. –  geekosaur Mar 13 '11 at 20:22
    
@geekosaur: Great comment! –  Tim Mar 13 '11 at 20:25

I could be wrong, but %U is a variable, possibly to open as the current user. see this answer for more details.

I updated my answer to link to the second answer, which is more accurate and detailed.

share|improve this answer
1  
Hmmm I think I'll do that next time :) –  Allan Mar 13 '11 at 20:43
1  
@Allan I know right? :D –  RolandiXor Mar 13 '11 at 23:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.