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.
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. If an application cannot handle multiple file arguments, the system must recognize this, and if it does, it will probably need to create and execute multiple copies of the application for each selected file. 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. If the Name key is missing, the .desktop filename without extension will probably be used.%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 « % » characterThunar 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 pathsBoth Nautilus and Thunar use specifiers which are deprecated by the Desktop Entry spec. They also use different meanings for
%n
.Dolphin supports the following options in addition to the main list:
%d
base directories of the selected files as separated arguments. behavior as in %f%D
base directories of the selected files as a single space-separated argument%n
basename of selected files as separated arguments. behavior as in %f%N
basenames of the selected files as a single space-separated argument%m
is similar to %fIf an unsupported parameter is used, Dolphin sends it simply as a string (e.g. "%M") and appends the paths to the selected files to it, as in %f.
If no one parameter is used, Dolphin still sends the paths to the selected files, as in %f.
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.