5

I'm talking about things like:

  • %B
  • %f
  • %F
  • %d
  • %D
  • etc.

What do they mean and how are they used? I'm looking either for a link to a tutorial, or somebody can post a comprehensive list for me here.

The goal is to add context menus to Pcmanfm/Lubuntu (assuming it's possible). If not possible with Pcmanfm, I'd try with another file manager.

I briefly tried Thunar and there was a list of parameters on it's action tool, but the list wasn't complete and I didn't understand the usage of some of the codes (I did read the tutorial). The information assumes a level of knowledge a little greater than mine. (Although I used context menus heavily in Windows, I generally used just one %-type parameter -- %s if I recall correctly.) So I'm looking for a master list and a comprehensive tutorial that explains usage of the parameters in Linux/Ubuntu.

Thanks.

8

A minimal list of these strings are defined in the section on the Exec key of the Desktop Entry specifications. The non-deprecated ones:

  • %f A single file name, even if multiple files are selected. The system reading the desktop entry should recognize that the program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple copies of a program for each selected file if the program is not able to handle additional file arguments. If files are not on the local file system (i.e. are on HTTP or FTP locations), the files will be copied to the local file system and %f will be expanded to point at the temporary file. Used for programs that do not understand the URL syntax.
  • %F A list of files. Use for apps that can open several local files at once. Each file is passed as a separate argument to the executable program.
  • %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.
  • %i The Icon key of the desktop entry expanded as two arguments, first --icon and then the value of the Icon key. Should not expand to any arguments if the Icon key is empty or missing.
  • %c The translated name of the application as listed in the appropriate Name key in the desktop entry.
  • %k The location of the desktop file as either a URI (if for example gotten from the vfolder system) or a local filename or empty if no location is known.

Not all of these make sense for custom actions. The LXDE Wiki suggests PCManFM supports only these.

Deprecated ones:

  • %d
  • %D
  • %n
  • %N
  • %v
  • %m

Nautilus Actions extends these to include a few more items, and I think most file managers follow that as a convention. Aside from those listed above, it adds:

  • %b (first) basename
  • %B space-separated list of basenames
  • %c count of selected items
  • %d (first) base directory
  • %D space-separated list of base directory of each selected items
  • %h hostname of the (first) URI
  • %m mimetype of the (first) selected item
  • %M space-separated list of the mimetypes of the selected items
  • %n username of the (first) URI
  • %o no-op operator which forces a form of execution when specified as first parameter, ignored else
  • %O no-op operator which forces a form of execution when specified as first parameter, ignored else
  • %p port number of the (first) URI
  • %s scheme of the (first) URI
  • %w (first) basename without the extension
  • %W space-separated list of basenames without their extension
  • %x (first) extension
  • %X space-separated list of extensions
  • %% the « % » character

Thunar Actions supports even fewer - the ones it supports are listed in the dialog for adding actions:

  • %f The path to the first selected file
  • %F The paths to all the selected files
  • %d Directory containing the file referred to by %f
  • %D Directories containing the files referred to by %F
  • %n The first selected filename, without the path
  • %N All the selected filenames, without paths

Both Nautilus and Thunar use specifiers which are deprecated by the Desktop Entry spec. They also use different meanings for %n.


To summarise, it seems the only common point between the Desktop Entry Spec, Nautilus Actions and Thunar is %f/%F. %f is used to specify a single file, and %F to specify a list of files.

| improve this answer | |
  • Wow. Many thanks for your comprehensive answer! It more than answers my questions. It will be a key reference for me in the future. – jackL Jun 6 '16 at 4:04
  • @jackL if the answer solved your problem, as you indicated, would you be so kind to accept the answer (tick the big "V" below the up/down arrows on the left). It is the appropriate way to indicate the answer worked for you. – Jacob Vlijm Jun 6 '16 at 5:29
  • Thanks for the tip. I hope I did it right. I clicked on the up arrow and it briefly turned red and displayed a 2. Then it went back to normal color and displayed 1. I need to find the site FAQ. :D – jackL Jun 7 '16 at 1:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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