Fix tools/check-headers.sh when builddir not equal to srcdir
[nautilus-actions.git] / docs / des-ema / des-ema-0.12
blob0f7b44852cd4c13bce805beaa0adf7200f841e4f
1 <?php
3 function code( $string ){
4 ?><code><font size="+1"><?php echo $string; ?></font></code><?php
7 function desktop(){
8     code( ".desktop" );
11 function directory(){
12     code( ".directory" );
17 <br />
19 <!-- ----------------------------------------------------------------------------- -->
21 <h2>Introduction</h2>
23 <p>
24 This specification aims to define a common format for user actions, allowing creators to share their actions between common environments.
25 </p>
26 <p>
27 The <?php desktop(); ?> file has been chosen as the common format for these actions.
28 </p>
29 <p>
30 As we would reuse the <a href="http://www.freedesktop.org/" target="_blank">freedesktop.org</a> <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank"> Desktop Entry Specification</a> (DES), we have to derive this specification to suit our needs.
31 </p>
32 <p>
33 This specification so defines how actions and menus should be described in <?php desktop(); ?> files, and how and where these <?php desktop(); ?> files are searched for.
34 </p>
35 <p>
36 This specification doesn't handle the &laquo;&nbsp;level-zero&nbsp;&raquo; case (but see the <a href="http://www.nautilus-actions.org/?q=node/377#level-zero">appendix A</a> for a proposition about that).
37 </p>
38 <p>
39 Such an extension, targeting action items in file manager context menu, has been widely discussed in <a href="https://mail.kde.org/mailman/listinfo/kde-devel" target="_blank">KDE</a>, <a href="http://lists.freedesktop.org/mailman/listinfo/xdg" target="_blank">freedesktop.org</a> and <a href="http://foo-projects.org/mailman/listinfo/thunar-dev" target="_blank">Thunar</a> lists.
40 </p>
41 <p>
42 This is version 0.12 of our draft, updated on 2010, June 15th (see <a href="http://www.nautilus-actions.org/?q=node/377#changelog">ChangeLog</a> below).
43 </p>
45 <!-- ----------------------------------------------------------------------------- -->
47 <h2>Desktop file</h2>
49 <h4>Desktop file format</h4>
51 <p>
52 This specification relies on the common syntax as defined in <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank"> DES</a>. We are just reminding here the reader of some main points.
53 </p>
54 <ul>
55 <li>Files are UTF-8 encoded.</li>
56 <li>All keys and values are case sensitive.</li>
57 <li>The <?php code( "[Desktop Entry]" ); ?> group must be the first group of the file.</li>
58 <li>Boolean values must be "<?php code( "true" ); ?>" or "<?php code( "false" ); ?>".</li>
59 <li>Strings, in strings lists, are semicolon-separated; the list itself ends with a semicolon.</li>
60 </ul>
61 <p>
62 Please note that, in all tables below, <?php code( "Req=YES" ); ?> just means that the value is required to define a valid action (resp. menu, resp. profile). A management UI is free to handle invalid actions (resp. menus, resp. profiles), and in fact that might even be needed in order to be able to fix invalid items, and make them valid...
63 </p>
65 <h4>Desktop file identifiant</h4>
67 <p>
68 In the rest of this specification, when a desktop file needs to be identified, we are using the basename of the file, without the extension, calling this a <i>desktop_file_id</i>.
69 </p>
71 <h4>Desktop files search path</h4>
73 <p>
74 <?php desktop(); ?> files are searched for in "<?php code( "XDG_DATA_DIRS/file-manager/actions" ); ?>" directories, as defined in <a href="http://www.freedesktop.org/" target="_blank">freedesktop.org</a> <a href="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html" target="_blank">XDG specifications</a>.
75 </p>
76 <p>
77 When building the whole hierarchy of the menus and actions to be displayed in the file manager context menu, the implementation should ensure that all used <i>desktop_file_ids</i> are unique. In the case where two <?php desktop(); ?> files have the same <i>desktop_file_id</i>, then the first found should take precedence.
78 </p>
80 <!-- ----------------------------------------------------------------------------- -->
82 <h2>Managed objects</h2>
84 <h4>Actions and profiles</h4>
86 <p>
87 This specification essentially defines how actions are to be described in <?php desktop(); ?> files in order to be displayed in a file manager context menu, and available as selectable items to be executed by the user.
88 </p>
89 <p>
90 An action might be defined as a group of several elements:
91 <ul>
92 <li>the displayable part: label, tooltip, icon</li>
93 <li>conditions which have to be met in order the item be actually displayed in the context menu; these conditions are checked against the current file manager selection; these might be mimetypes, protocols, etc.</li>
94 <li>the command to be executed, and its parameters.</li>
95 </ul>
96 </p>
97 <p>
98 As a user might want have the very same action (same label, same icon, and so on) execute a different command depending of the current environment at runtime, we define that an action is built on one to several profiles, where each profile is defined by:</li>
99 <ul>
100 <li>conditions which have to be met in order the item be actually displayed in the context menu; these conditions are checked against the current file manager selection; these might be mimetypes, protocols, etc.</li>
101 <li>the command to be executed, and its parameters.</li>
102 </ul>
103 </p>
105 <h4>Menus</h4>
108 This specification also defines how these actions may be gathered and ordered in menus, and submenus, and so on.
109 </p>
111 A menu is defined by:
112 <ul>
113 <li>its displayable part: label, tooltip, icon</li>
114 <li>a set of conditions which are to be met in order the menu, and recursively all of its subitems, be actuelly displayed in the file manager context menu</li>
115 <li>the ordered list of the items in the menu.</li>
116 </ul>
117 </p>
119 <h4>Conditions</h4>
122 As we are dealing with three level of objects (menus, actions, profiles), it appears that whether a condition must be defined at one of these levels is rather an arbitrary decision.
123 </p>
125 We so say that conditions may appear in any of these levels:
126 </p>
127 <ul>
128 <li>When a condition appears in a menu definition, the result of its evaluation recursively applies to all included items. If the condition is not met, then neither the menu nor any of its subitems will be displayed.</li>
129 <li>When a condition appears in an action definition, the result of its evaluation applies to all its profiles. If the condition is not met, then the action will not be candidate; the profiles will even not be considered.</li>
130 </ul>
132 <!-- ----------------------------------------------------------------------------- -->
134 <h2>Action definition</h2>
137 An action must be entirely defined in one <?php desktop(); ?> file. The action is identified by the <i>desktop_file_id</i> in which it is defined.
138 </p>
140 Only valid actions are displayed in the file manager context menu.
141 </p>
143 To be valid, an action must have a non-empty label, and at least one profile must be found valid at runtime.
144 </p>
146 An action is primarily defined in the <?php code( "[Desktop Entry]" ); ?> group, which has following keys:
147 </p>
149 <table border="1">
150 <tr valign="top">
151 <td><b>Key</b></td>
152 <td><b>Description</b></td>
153 <td nowrap="nowrap"><b>Value type</b></td>
154 <td><b>Req&nbsp;?</b></td>
155 </tr>
157 <tr valign="top">
158 <td><?php code( "Type" ); ?></td>
159 <td>This define this <?php desktop(); ?> file as an Action definition.<br />
160 Defaults to "<?php code( "Action" ); ?>".</td>
161 <td>string</td>
162 <td>no</td>
163 </tr>
165 <tr valign="top">
166 <td><?php code( "Name" ); ?></td>
167 <td>The label of the action, as it should appear in the context menu.<br />
168 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "Name" ); ?> value, and will be substituted at runtime.</td>
169 <td>localestring</td>
170 <td>YES</td>
171 </tr>
173 <tr valign="top">
174 <td><?php code( "Tooltip" ); ?></td>
175 <td>The tooltip associated with the item in the context menu.<br />
176 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "Tooltip" ); ?> value, and will be substituted at runtime.<br />
177 Defaults to empty.
178 </td>
179 <td>localestring</td>
180 <td>no</td>
181 </tr>
183 <tr valign="top">
184 <td><?php code( "Icon" ); ?></td>
185 <td>The name of a themed icon, or the path to an icon.<br />
186 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "Icon" ); ?> value, and will be substituted at runtime.<br />
187 Defaults to empty.</td>
188 <td>localestring</td>
189 <td>no</td>
190 </tr>
192 <tr valign="top">
193 <td><?php code( "Description" ); ?></td>
194 <td>A free description of the action, which may be used in the management UI, in a Web page, and so on.<br />
195 Defaults to empty.</td>
196 <td>localestring</td>
197 <td>no</td>
198 </tr>
200 <tr valign="top">
201 <td><?php code( "SuggestedShortcut" ); ?></td>
202 <td>A shortcut suggested for the action.<br />
203 Please note that this might be only a suggestion as the shortcut may be already reserved for another use. Implementation should not override an already existing shortcut to define this one.<br />
204 The format may look like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1".<br />
205 Defaults to empty.</td>
206 <td>string</td>
207 <td>no</td>
208 </tr>
210 <tr valign="top">
211 <td><?php code( "Enabled" ); ?></td>
212 <td>Whether the item is candidate to be displayed in the context menu.<br />
213 A user might define many actions or menus, and choose to only enable some of them from time to time.<br />
214 Defaults to "<?php code( "true" ); ?>".</td>
215 <td>boolean</td>
216 <td>no</td>
217 </tr>
219 <tr valign="top">
220 <td><?php code( "Hidden" ); ?></td>
221 <td>From <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">DES</a>: <?php code( "Hidden" ); ?> should have been called <?php code( "Deleted" ); ?>. It means the user deleted (at his level) something that was present (at an upper level, e.g. in the system dirs). It's strictly equivalent to the <?php desktop(); ?> file not existing at all, as far as that user is concerned. This can also be used to "uninstall" existing files (e.g. due to a renaming) - by letting make install install a file with <?php code( "Hidden=true" ); ?> in it.<br />
222 Defaults to "<?php code( "false" ); ?>".</td>
223 <td>boolean</td>
224 <td>no</td>
225 </tr>
227 <tr valign="top">
228 <td><?php code( "TargetContext" ); ?></td>
229 <td>Whether the item targets the file manager context menu.<br />
230 This means that the action will be candidate if defined conditions met the current selection.<br />
231 Defaults to "<?php code( "true" ); ?>".</td>
232 <td>boolean</td>
233 <td>no</td>
234 </tr>
236 <tr valign="top">
237 <td><?php code( "TargetLocation" ); ?></td>
238 <td>Whether the item targets a location menu, if the file manager supports this.<br />
239 This means that the action will be candidate if defined conditions met the current location.<br />
240 Defaults to "<?php code( "false" ); ?>".</td>
241 <td>boolean</td>
242 <td>no</td>
243 </tr>
245 <tr valign="top">
246 <td><?php code( "TargetToolbar" ); ?></td>
247 <td>Whether the item targets the toolbar, if the file manager supports this.<br />
248 Note that, in order to keep a nice and stable UI, the file manager may reserve toolbar actions to those only targeting the current folder.<br />
249 Defaults to "<?php code( "false" ); ?>".</td>
250 <td>boolean</td>
251 <td>no</td>
252 </tr>
254 <tr valign="top">
255 <td><?php code( "ToolbarLabel" ); ?></td>
256 <td>The label to be displayed in the toolbar, if it is not the same that those displayed in context menu.<br />
257 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "ToolbarLabel" ); ?> value, and will be substituted at runtime.<br />
258 Defaults to <?php code( "Name" ); ?> value.</td>
259 <td>localestring</td>
260 <td>no</td>
261 </tr>
263 <tr valign="top">
264 <td nowrap="nowrap"><?php code( "Profiles" ); ?></td>
265 <td><p>The ordered list of the profiles attached to this action.<br />
266 Each element of this strings list may be:
267 <ul>
268  <li>a <i>profile_id</i>, <i>i.e.</i> the id of a profile, as an ASCII string</li>
269  <li>a command to be executed, if the string is enclosed between square brackets ('<?php code( "[" ); ?>'...'<?php code( "]" ); ?>').</li>
270 </ul>
272 So, "<?php code( "Profiles" ); ?>" key has a dynamic value: if an element of the string list is enclosed between square brackets ('<?php code( "[" ); ?>'...'<?php code( "]" ); ?>'), it is considered as a command, optionally with <a href="http://www.nautilus-actions.org/?q=node/377#parameters">parameters</a> and arguments, and so will be subject to an evaluation at runtime. If the standard output of the command is a valid strings list, then it is substituted to the bracketed element. It the command doesn't exist or cannot be executed, the bracketed element is just ignored.
273 </p>
275 After reading, and maybe evaluation of dynamic elements, profiles identified by the "<?php code( "Profiles" ); ?>" value, but not found in this <?php desktop(); ?> file, are just ignored.
276 </p>
278 It is up to the implementation to decide whether profiles found in this <?php desktop(); ?> file, but not identified in this list, should or not be attached to the action.<br/>
279 It could be for example an acceptable fallback to append these &laquo;&nbsp;orphan&nbsp;&raquo; profiles at the end of the list of profiles.<br />
280 Another choice might also be:
281 </p>
282 <ul>
283 <li>at runtime, only attach to the action profiles which are listed in this "<?php code( "Profiles" ); ?>" key</li>
284 <li>while a management UI may load all profiles found in the <?php desktop(); ?> file.</li>
285 </ul>
286 </td>
287 <td>strings list</td>
288 <td>YES</td>
289 </tr>
291 </table>
293 <!-- ----------------------------------------------------------------------------- -->
295 <h2>Profile definition</h2>
298 Profile is identified by its <i>profile_id</i>, as an ASCII string.
299 </p>
301 Each profile defined in the "<?php code( "Profiles" ); ?>" key, whether statically by its <i>profile_id</i> identifiant, or as the result of an evaluated command, must be defined in a <?php code( "[X-Action-Profile <i>profile_id</i>]" ); ?> group.
302 </p>
304 When several profiles are defined for an action, only the first valid profile whose conditions are met at runtime is selected to be made available in the context menu.
305 </p>
307 Defining several profiles let so the user have ordered OR-ed set of conditions, i.e. have one action be available if one set of conditions is met, OR this same action, though most probably with a slightly different command, be available if another set of conditions is met, and so on.
308 </p>
310 In order to be valid, a profile must at least have an executable command.
311 </p>
313 <table border="1">
314 <tr valign="top">
315 <td><b>Key</b></td>
316 <td><b>Description</b></td>
317 <td nowrap="nowrap"><b>Value type</b></td>
318 <td><b>Req&nbsp;?</b></td>
319 </tr>
321 <tr valign="top">
322 <td><?php code( "Name" ); ?></td>
323 <td>The name of the profile; this name is not displayed in the context menu, and should just be thought as a convenience for the management UI. It may also be seen as a good place for a description of what the profile exactly does.<br />
324 Defaults to empty.</td>
325 <td>localestring</td>
326 <td>no</td>
327 </tr>
329 <tr valign="top">
330 <td><?php code( "Exec" ); ?></td>
331 <td>From <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">DES</a>: program to execute, possibly with arguments<br />
332 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "Exec" ); ?> value, and will be substituted at runtime.
333 </td>
334 <td>string</td>
335 <td>YES</td>
336 </tr>
338 <tr valign="top">
339 <td><?php code( "Path" ); ?></td>
340 <td>The working directory the program should be started in.<br />
341 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "Path" ); ?> value, and will be substituted at runtime.<br />
342 Defaults to base directory of the current selection, which happens to be the value of "<?php code( "%d" ); ?>" parameter.
343 </td>
344 <td>string</td>
345 <td>no</td>
346 </tr>
348 <tr valign="top">
349 <td><?php code( "ExecutionMode" ); ?></td>
350 <td>Execution mode of the program.<br />
351 This may be chosen between following values:
352 <ul>
353 <li><?php code( "Normal" ); ?>: Starts as a standard graphical user interface</li>
354 <li><?php code( "Terminal" ); ?>: Starts the preferred terminal of the graphical environment, and runs the command in it</li>
355 <li><?php code( "Embedded" ); ?>: Makes use of a special feature of the file manager which allows a terminal to be ran inside of it; an acceptable fallback is <?php code( "Terminal" ); ?></li>
356 <li><?php code( "DisplayOutput" ); ?>: The ran terminal may be closed at end of the command, but standard streams (stdout, stderr) should be collected and displayed; an acceptable fallback is <?php code( "Terminal" ); ?></li>
357 </ul>
358 Defaults to "<?php code( "Normal" ); ?>".
359 </td>
360 <td>string</td>
361 <td>no</td>
362 </tr>
364 <tr valign="top">
365 <td><?php code( "StartupNotify" ); ?></td>
366 <td>From <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">DES</a>: if "<?php code( "true" ); ?>", it is KNOWN that the application will send a "remove" message when started with the DESKTOP_STARTUP_ID environment variable set. If "<?php code( "false" ); ?>", it is KNOWN that the application does not work with startup notification at all (does not shown any window, breaks even when using StartupWMClass, etc.). If absent, a reasonable handling is up to implementations (assuming false, using StartupWMClass, etc.). (See the <a href="http://www.freedesktop.org/Standards/startup-notification-spec">Startup Notification Protocol Specification</a> for more details).<br />
367 Only relevant when <?php code( "ExecutionMode=Normal" ); ?>.<br />
368 Defaults to "<?php code( "false" ); ?>".</td>
369 <td>boolean</td>
370 <td>no</td>
371 </tr>
373 <tr valign="top">
374 <td><?php code( "StartupWMClass" ); ?></td>
375 <td>From <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">DES</a>: if specified, it is known that the application will map at least one window with the given string as its WM class or WM name hint (see the <a href="http://www.freedesktop.org/Standards/startup-notification-spec">Startup Notification Protocol Specification</a> for more details). <br />
376 Only relevant when <?php code( "ExecutionMode=Normal" ); ?>.<br />
377 Defaults to empty.</td>
378 <td>string</td>
379 <td>no</td>
380 </tr>
382 <tr valign="top">
383 <td><?php code( "ExecuteAs" ); ?></td>
384 <td>The user the command must be ran as. The user may be identified by its numeric UID or by its login.<br />
385 The implementation should ignore a profile defining a non-existing UID or login as a value for the <?php code( "ExecuteAs" ); ?> key.<br />
386 The implementation might require the presence of a well-configured subsystem (e.g. sudo).<br />
387 Defaults to empty: the command will be executed as the current user.</td>
388 <td>string</td>
389 <td>no</td>
390 </tr>
391 </table>
393 <!-- ----------------------------------------------------------------------------- -->
395 <h2>Menu definition</h2>
398 Just as an action, a menu has label, tooltip, icon.
399 </p>
401 But, where an action is intended to eventually execute a command, a menu is just a way of gathering some subitems, actions or menus, in an ordered list.
402 </p>
404 In order to be valid, a menu must have a non-empty name, and include at least one valid subitem.
405 </p>
407 It is the responsability of the implementation to ensure that the displayed menus are relevant, <i>i.e.</i> not empty, with no separator at the begin or the end of the menu, with no double separator, etc.
408 </p>
410 The menu is so defined as a particular case of a <?php desktop(); ?> file, identified by its <i>desktop_file_id</i>, whose the <?php code( "[Desktop Entry]" ); ?> section has following keys:
411 </p>
413 <table border="1">
414 <tr valign="top">
415 <td nowrap="nowrap"><b>Key</b></td>
416 <td><b>Description</b></td>
417 <td nowrap="nowrap"><b>Value type</b></td>
418 <td><b>Req&nbsp;?</b></td>
419 </tr>
421 <tr valign="top">
422 <td><?php code( "Type" ); ?></td>
423 <td>This define this <?php desktop(); ?> file as a Menu definition.<br />
424 Must be equal to "<?php code( "Menu" ); ?>".</td>
425 <td>string</td>
426 <td>YES</td>
427 </tr><tr valign="top">
428 <td><?php code( "Name" ); ?></td>
429 <td>The label of the menu, as it should appear in the context menu.<br />
430 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "Name" ); ?> value, and will be substituted at runtime.</td>
431 <td>localestring</td>
432 <td>YES</td>
433 </tr>
435 <tr valign="top">
436 <td><?php code( "Tooltip" ); ?></td>
437 <td>The tooltip associated with the submenu in the context menu.<br />
438 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "Tooltip" ); ?> value, and will be substituted at runtime.<br />
439 Defaults to empty.
440 </td>
441 <td>localestring</td>
442 <td>no</td>
443 </tr>
445 <tr valign="top">
446 <td><?php code( "Icon" ); ?></td>
447 <td>The name of a themed icon, or the path to an icon, to be associated to the submenu.<br />
448 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "Icon" ); ?> value, and will be substituted at runtime.<br />
449 Defaults to empty.</td>
450 <td>localestring</td>
451 <td>no</td>
452 </tr>
454 <tr valign="top">
455 <td><?php code( "Description" ); ?></td>
456 <td>A free description of the menu, which may be used in the management UI, in a Web page, and so on.<br />
457 Defaults to empty.</td>
458 <td>localestring</td>
459 <td>no</td>
460 </tr>
462 <tr valign="top">
463 <td><?php code( "SuggestedShortcut" ); ?></td>
464 <td>A shortcut suggested for the menu.<br />
465 Please note that this might be only a suggestion as the shortcut may be already reserved for another use. Implementation should not override an already existing shortcut to define this one.<br />
466 The format may look like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1".<br />
467 Defaults to empty.</td>
468 <td>string</td>
469 <td>no</td>
470 </tr>
472 <tr valign="top">
473 <td><?php code( "Enabled" ); ?></td>
474 <td>Whether the item is candidate to be displayed in the context menu.<br />
475 A user might define many actions or menus, and choose to only enable some of them from time to time.<br />
476 Defaults to "<?php code( "true" ); ?>".</td>
477 <td>boolean</td>
478 <td>no</td>
479 </tr>
481 <tr valign="top">
482 <td><?php code( "Hidden" ); ?></td>
483 <td>From <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">DES</a>: <?php code( "Hidden" ); ?> should have been called <?php code( "Deleted" ); ?>. It means the user deleted (at his level) something that was present (at an upper level, e.g. in the system dirs). It's strictly equivalent to the <?php desktop(); ?> file not existing at all, as far as that user is concerned. This can also be used to "uninstall" existing files (e.g. due to a renaming) - by letting make install install a file with <?php code( "Hidden=true" ); ?> in it.<br />
484 Defaults to "<?php code( "false" ); ?>".</td>
485 <td>boolean</td>
486 <td>no</td>
487 </tr>
489 <tr valign="top">
490 <td nowrap="nowrap" id="itemslist"><?php code( "ItemsList" ); ?></td>
491 <td><p>The ordered list of the items (actions or menus) attached to this menu.<br />
492 Each element of this strings list may be:
493 <ul>
494 <!--
495  Wrong formulation because this prevent to use GConf uuid
496  <li>a <i>desktop_file_id</i>, <i>i.e.</i> the id of a <?php desktop(); ?> file which describes an action or a menu,</li>
497  -->
498  <li>the id of an action or a menu,</li>
499  <li>a command to be executed, if the string is enclosed between square brackets ('<?php code( "[" ); ?>'...'<?php code( "]" ); ?>').</li>
500 </ul>
501 So, "<?php code( "ItemsList" ); ?>" key has a dynamic value: if an element of the string list is enclosed between square brackets ('<?php code( "[" ); ?>'...'<?php code( "]" ); ?>'), it is considered as a command, optionally with <a href="http://www.nautilus-actions.org/?q=node/377#parameters">parameters</a> and arguments, and so will be subject to an evaluation at runtime. If the standard output of the command is a valid strings list, then it is substituted to the bracketed element. It the command doesn't exist or cannot be executed, the bracketed element is just ignored.
502 </p>
504 The keyword <?php code( "SEPARATOR" ); ?> is a special case of <i>desktop_file_id</i>. It may be used to define a separator in the menu.
505 </p>
507 Actions or menus not identified here, or not identified as subitems of a menu or of a submenu, should not be ignored by the implementation; instead of that, the implementation should display these &laquo;&nbsp;orphan&nbsp;&raquo; items (though in a unspecified order).
508 </p>
509 </td>
510 <td>strings list</td>
511 <td>YES</td>
512 </tr>
514 </table>
516 <!-- ----------------------------------------------------------------------------- -->
518 <h2>Conditions</h2>
521 As a remainder of that has been said above, each one of the following conditions may appear in a menu, an action or a profile.
522 </p>
524 Conditions are AND-ed, that is all specified conditions which appear in a menu, an action or a profile must be met in order the item be considered as a candidate.
525 </p>
527 When a condition is defined as a string list, elements of the list are considered as OR-ed (but for <a href="http://www.nautilus-actions.org/?q=node/377#capabilities">Capabilities</a>).<br />
528 When an element of the string list is negated, it must be considered as an AND condition.
529 </p>
530 <p>Example:</p>
531 <blockquote>
532  <p>
533  The line &laquo;&nbsp;<?php code( "MimeTypes = image/*; video/*;" ); ?>&nbsp;&raquo; must be read as &laquo;&nbsp;condition is met if each file in the current selection has a mimetype of "<?php code( "image/*" ); ?>" or of "<?php code( "video/*" ); ?>"&nbsp;&raquo;
534   </p>
535   <p>And the line &laquo;&nbsp;<?php code( "MimeTypes = image/*; video/*; !image/bmp" ); ?>&nbsp;&raquo; must be read as &laquo;&nbsp;condition is met if each file in the current selection has a mimetype of "<?php code( "image/*" ); ?>" or of "<?php code( "video/*" ); ?>", but must not have the "<?php code( "image/bmp" ); ?>" mimetype&nbsp;&raquo;.
536   </p>
537 </blockquote>
539 <table border="1">
540 <tr valign="top">
541 <td><b>Key</b></td>
542 <td><b>Description</b></td>
543 <td nowrap="nowrap"><b>Value type</b></td>
544 <td><b>Req&nbsp;?</b></td>
545 </tr>
547 <tr valign="top">
548 <td><?php code( "OnlyShowIn" ); ?>,<br /><?php code( "NotShowIn" ); ?></td>
549 <td>From <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">DES</a>: a list of strings identifying the environments that should display/not display a given desktop entry. Only one of these keys, either <?php code( "OnlyShowIn" ); ?> or <?php code( "NotShowIn" ); ?>, may appear in a group (for possible values see the <a href="http://www.freedesktop.org/Standards/menu-spec">Desktop Menu Specification</a>).<br />
550 Defaults to show anywhere.</td>
551 <td nowrap="nowrap">strings list</td>
552 <td>no</td>
553 </tr>
555 <tr valign="top">
556 <td><?php code( "TryExec" ); ?></td>
557 <td>Fromn <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">DES</a>: path to an executable file on disk used to determine if the program is actually installed. If the path is not an absolute path, the file is looked up in the $PATH environment variable. If the file is not present or if it is not executable, the entry may be ignored.<br />
558 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "TryExec" ); ?> value, and will be substituted at runtime.<br />
559 Defaults to successful.</td>
560 <td>string</td>
561 <td>no</td>
562 </tr>
564 <tr valign="top">
565 <td><?php code( "ShowIfRegistered" ); ?></td>
566 <td>The well-known name of a DBus service.<br />
567 The item will be candidate if the named service is registered on session DBus at runtime.<br />
568 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "ShowIfRegistered" ); ?> value, and will be substituted at runtime.<br />
569 Defaults to successful.<br />
570     <table border="0">
571     <tr>
572     <td valign="top"><i>Comment:</i></td>
573     <td valign="top"><i>This is the equivalent of KDE "<?php code( "X-KDE-ShowIfRunning" ); ?>" key.</i></td>
574     </tr>
575     </table>
576 </td>
577 <td>string</td>
578 <td>no</td>
579 </tr>
581 <tr valign="top">
582 <td><?php code( "ShowIfTrue" ); ?></td>
583 <td>A command which, when executed, should output a string on stdout.<br />
584 The item will be candidate if the outputed string is equal to "<?php code( "true" ); ?>".<br />
585 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "ShowIfTrue" ); ?> value, and will be substituted at runtime.<br />
586 Example: <?php code( "[ -r %d/.svn/entries ] && echo \"true\"" ); ?><br />
587 Defaults to successful.<br />
588     <table border="0">
589     <tr>
590     <td valign="top"><i>Comment:</i></td>
591     <td valign="top"><i>This is the equivalent of KDE "<?php code( "X-KDE-ShowIfDBusCall" ); ?>" key, extended to any command able to output a string.</i></td>
592     </tr>
593     </table>
594 </td>
595 <td>string</td>
596 <td>no</td>
597 </tr>
599 <tr valign="top">
600 <td><?php code( "ShowIfRunning" ); ?></td>
601 <td>The name of a process.<br />
602 The item will be candidate if the process name is found in memory at runtime.<br />
603 <a href="http://www.nautilus-actions.org/?q=node/377#parameters">Parameters</a> may appear in <?php code( "ShowIfRunning" ); ?> value, and will be substituted at runtime.<br />
604 Defaults to successful.
605 </td>
607 <td>string</td>
608 <td>no</td>
609 </tr>
610 <tr valign="top">
611 <td><?php code( "MimeTypes" ); ?></td>
612 <td>From <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">DES</a>: the MIME type(s) supported by this application.<br />
613 Each mimetype may be fully specified (e.g. "<?php code( "audio/mpeg;" ); ?>"), or as a group (e.g. "<?php code( "image/*;" ); ?>").<br />
614 Mimetypes may be negated (e.g. "<?php code( "audio/*; !audio/mpeg;" ); ?>").<br />
615 Some of well-known mimetypes include:<br />
616 <ul>
617 <li>"<?php code( "all/all" ); ?>": matches all items</li>
618 <li>"<?php code( "all/allfiles" ); ?>": matches only files</li>
619 <li>"<?php code( "inode/directory" ); ?>": matches only directories</li>
620 </ul>
621 '<?php code( "*" ); ?>' character is accepted as a wildcard in only two cases:
622 <ul>
623  <li>when used alone as in "<?php code( "*;" ); ?>", <i>i.e.</i> when used as a group wildcard without subgroup,</li>
624  <li>when used as the subgroup wildcard, after the '<?php code( "/" ); ?>' character, as in "<?php code( "image/*" ); ?>".</li>
625 </ul>
626 Defaults to "<?php code( "*;" ); ?>", which happends to be exactly equivalent to "<?php code( "all/all" ); ?>" or to "<?php code( "all/*" ); ?>".
627     <table border="0">
628     <tr>
629     <td valign="top"><i>Comment:</i></td>
630     <!--
631     <td valign="top"><i>Do we should include "<?php code( "allfiles" ); ?>" mimetype, which seems obsolete, in order to keep compatibility with some old versions of KDE ?</i></td>
632     </tr>
633     <tr>
634     -->
635     <td></td>
636     <td><i>This is the equivalent of "<?php code( "ServiceTypes" ); ?>", "<?php code( "X-KDE-ServiceTypes" ); ?>", "<?php code( "ExcludeServiceTypes" ); ?>" KDE and "<?php code( "MimeType" ); ?>" freedesktop keys.</i></td>
637     </tr>
638     </table>
639 </td>
640 <td>strings list</td>
641 <td>no</td>
642 </tr>
644 <tr valign="top">
645 <td><?php code( "Basenames" ); ?></td>
646 <td>List of basenames the selection should match in order this profile be selected.<br />
647 '<?php code( "*" ); ?>' character is accepted as a wildcard.<br />
648 Basenames may be negated (e.g. "<?php code( "*; !*.h;" ); ?>").<br />
649 Defaults to "<?php code( "*;" ); ?>".</td>
650 <td>strings list</td>
651 <td>no</td>
652 </tr>
654 <tr valign="top">
655 <td><?php code( "Matchcase" ); ?></td>
656 <td>Whether the above <?php code( "Basenames" ); ?> is case sensitive.<br />
657 Defaults to "<?php code( "true" ); ?>".</td>
658 <td>boolean</td>
659 <td>no</td>
660 </tr>
662 <tr valign="top">
663 <td id="selection-count"><?php code( "SelectionCount" ); ?></td>
664 <td>Whether this profile may be selected depending of the count of the selection.<br />
665 This is a string of the form "<?php code( "{'<'|'='|'>'} number" ); ?>".<br />
666 Examples of valid strings are: "<?php code( "=0" ); ?>", "<?php code( "> 1" ); ?>", "<?php code( "< 10" ); ?>".<br />
667 Defaults to "<?php code( ">0" ); ?>".
668 </td>
669 <td>string</td>
670 <td>no</td>
671 </tr>
673 <tr valign="top">
674 <td><?php code( "Schemes" ); ?></td>
675 <td>The list of schemes the selection must satisfy in order the item be selected.<br />
676 Exemples of well-known schemes are:<br />
677 <ul>
678 <li>"<?php code( "file" ); ?>"</li>
679 <li>"<?php code( "sftp" ); ?>"</li>
680 <li>"<?php code( "smb" ); ?>"</li>
681 <li>"<?php code( "http" ); ?>"</li>
682 </ul>
683 Schemes may be negated, e.g. "<?php code( "!http;" ); ?>".<br />
684 Defaults to "<?php code( "*;" ); ?>".
685     <table border="0">
686     <tr>
687     <td valign="top"><i>Comment:</i></td>
688     <td valign="top"><i>This is the equivalent of "<?php code( "X-KDE-Protocol" ); ?>" and "<?php code( "X-KDE-Protocols" ); ?>" KDE keys.</i></td>
689     </tr>
690     <!--
691     <tr>
692     <td></td>
693     <td><i>Does a "Protocols" key would be better understood than a "Schemes" key ?</i></td>
694     </tr> 
695     -->
696     </table>
697 </td>
698 <td>strings list</td>
699 <td>no</td>
700 </tr>
702 <tr valign="top">
703 <td><?php code( "Folders" ); ?></td>
704 <td>A list of paths the current base directory must be in in order the item be selected.<br />
705 A folder path may be negated (e.g. "<?php code( "/data; !/data/resources/secret;" ); ?>").<br />
706 '<?php code( "*" ); ?>' character is accepted as a wildcard, replacing any level(s) of subdirectory (e.g. "<?php code( "/music; /video; !*/secret;" ); ?>").<br />
707  Also note that a terminating '<?php code( "/*" ); ?>' is always implied by the definition of this key.<br />
708  Last, note that different implementations today widely consider that, for a directory point of view, having no selection is roughly the same that selecting the currently opened folder. If this makes a difference for your action, then <a href="http://www.nautilus-actions.org/?q=node/377#selection-count">SelectionCount</a> is for you.
709 Defaults to "<?php code( "/" ); ?>".</td>
710 <td>strings list</td>
711 <td>no</td>
712 </tr>
714 <tr valign="top">
715 <td id="capabilities"><?php code( "Capabilities" ); ?></td>
716 <td>A list of capabilities each item of the selection must satisfy in order the item be candidate.<br />
717 Capabilities may be negated.<br />
718 Please note that each element of the specified list must be considered as ANDed, i.e. if we have "<?php code( "Capabilities=Readable;Writable;!Local" ); ?>", then each element of the selection must be both readable AND writable AND not local.<br />
719 Capabilities have to be chosen between following predefined ones:
720 <ul>
721 <li>"<?php code( "Owner" ); ?>": current user is the owner of selected items</li>
722 <li>"<?php code( "Readable" ); ?>": selected items are readable by user (probably more usefull when negated)</li>
723 <li>"<?php code( "Writable" ); ?>": selected items are writable by user</li>
724 <li>"<?php code( "Executable" ); ?>": selected items are executable by user</li>
725 <li>"<?php code( "Local" ); ?>": selected items are local</li>
726 </ul>
727 Defaults to an empty list (do not care of capabilities).
728     <table border="0">
729     <tr>
730     <td valign="top"><i>Comment:</i></td>
731     <td valign="top"><i>This is the equivalent of "<?php code( "X-KDE-Require" ); ?>" KDE key.</i></td>
732     </tr>
733     <!--
734     <tr>
735     <td></td>
736     <td><i>Some other relevant capabilities ?</i></td>
737     </tr>
738     -->
739     </table>
740 </td>
741 <td>strings list</td>
742 <td>no</td>
743 </tr>
745 </table>
747 <!-- ----------------------------------------------------------------------------- -->
749 <h2 id="parameters">Parameters</h2>
752 Whenever parameters are said to be accepted, they will be replaced at run-time.
753 </p>
755 Also, this specification doesn't make any assumption about whether a parameter is relevant in a given situation, or secure, or may be used several times, or so. It instead considers that this sort of check is up to the action creator.
756 </p>
758 The implementation should take care of correctly shell-escape the substituted values, so that it should not be needed for the action creator to use any sort of quotes to handle spaces in filenames.
759 </p>
761 Though some parameters are not sensible to the count of the selection (e.g. "<?php code( "%c" ); ?>", the selection count itself), most have two declensions:
762  <ul>
763   <li>a "singular" one, e.g. "<?php code( "%b" ); ?>", the basename of the selected item</li>
764   <li>a "plural" one, e.g. "<?php code( "%B" ); ?>", a space-separated list of the basenames of selected items</li>
765  </ul>
766  When the selection is empty or contains only one element, these two forms are exactly equivalent.<br />
767  When the selection contains more than one item:
768  <ul>
769   <li>if the first parameter found in the <?php code( "Exec" ); ?> key is of a singular form, then the implementation should consider that the command is only able to deal with one item at a time, and thus that it has to be ran one time for each selected item;<li>
770   <li>contrarily, if the first parameter found is of the plural form, then the implementation should consider that the command is able to deal with a list of items, and thus the command should be executed only once.</li>
771  </ul>
772 </p>
774 Example:
775 </p>
776 <blockquote>
777  <p>
778   Say the current folder is /data, and the current selection contains the three files <?php code( "pierre" ); ?>, <?php code( "paul" ); ?> and <?php code( "jacques" ); ?>.
779   </p>
780  <p>
781   If the <?php code( "Exec" ); ?> key is "<?php code( "echo %b" ); ?>", then the following commands will be run:<br />
782        "<?php code( "echo pierre" ); ?>"<br />
783        "<?php code( "echo paul" ); ?>"<br />
784        "<?php code( "echo jacques" ); ?>"<br />
785   </p>
786   <p>
787    If the <?php code( "Exec" ); ?> key is "<?php code( "echo %B" ); ?>", then the following command will be run:<br />
788        "<?php code( "echo pierre paul jacques" ); ?>"
789   </p>
790   <p>
791   If the <?php code( "Exec" ); ?> key is "<?php code( "echo %b %B" ); ?>", then the following commands will be run:<br />
792        "<?php code( "echo pierre pierre paul jacques" ); ?>"<br />
793        "<?php code( "echo paul pierre paul jacques" ); ?>"<br />
794        "<?php code( "echo jacques pierre paul jacques" ); ?>"<br />
795   </p>
796   <p>
797   If the <?php code( "Exec" ); ?> key is "<?php code( "echo %B %b" ); ?>", then the following commands will be run:<br />
798        "<?php code( "echo pierre paul jacques pierre" ); ?>"<br />
799   The basename used is those of the first item of the selected items list as provided by the file manager. There is only a small chance that it would be those of the first visually selected item, and there is contrarily great chances that it would not be predictable at all.
800   </p>
801   <p>
802    Even if the chosen parameter is the same for all selected items, the behavior is the identical.<br />
803    If the <?php code( "Exec" ); ?> key is "<?php code( "echo %d %B" ); ?>", then the following commands will be run:<br />
804        "<?php code( "echo /data pierre paul jacques" ); ?>"<br />
805        "<?php code( "echo /data pierre paul jacques" ); ?>"<br />
806        "<?php code( "echo /data pierre paul jacques" ); ?>"<br />
807     which obviously doesn't make many sense.
808   </p>
809   <p>
810    As the last three examples show up, action creator should avoid to mix singular and plural forms, unless they know what they are doing, whether it doesn't make sense or this may lead to unwaited results.
811   </p>
812   <p>
813    Nonetheless, mixing singular and plural forms, though we warn against, is not an error. As a counter example, there may be some situations where a command-line of the form "<?php code( "echo %B %d" ); ?>" would be useful. In that case, the following command would be run:<br />
814        "<?php code( "echo pierre paul jacques /data" ); ?>"<br />
815     It is left as an exercize for the reader to find a use case.
816   </p>
817 </blockquote>
820 The word "first" in the following table makes so reference to the case where the singular form parameter is used in a plural form command. We recall one more time that which is the "first" element is not specified, and, most probably, rather unpredictable.
821 </p>
823 <table border="1">
824 <tr valign="top">
825 <td align="center"><b>Parameter</b></td>
826 <td><b>Description</b></td>
827 </tr>
829 <tr valign="top">
830 <td align="center">%b</td>
831 <td>(first) basename</td>
832 </tr>
834 <tr valign="top">
835 <td align="center">%B</td>
836 <td>space-separated list of basenames</td>
837 </tr>
839 <tr valign="top">
840 <td align="center">%c</td>
841 <td>count of selected items</td>
842 </tr>
844 <tr valign="top">
845 <td align="center">%d</td>
846 <td>(first) base directory</td>
847 </tr>
849 <tr valign="top">
850 <td align="center">%D</td>
851 <td>space-separated list of base directory of each selected items</td>
852 </tr>
854 <tr valign="top">
855 <td align="center">%f</td>
856 <td>(first) file name</td>
857 </tr>
859 <tr valign="top">
860 <td align="center">%F</td>
861 <td>space-separated list of selected file names</td>
862 </tr>
864 <tr valign="top">
865 <td align="center">%h</td>
866 <td>hostname of the (first) URI</td>
867 </tr>
869 <tr valign="top">
870 <td align="center">%n</td>
871 <td>username of the (first) URI</td>
872 </tr>
874 <tr valign="top">
875 <td align="center">%p</td>
876 <td>port number of the (first) URI</td>
877 </tr>
879 <tr valign="top">
880 <td align="center">%s</td>
881 <td>scheme of the (first) URI</td>
882 </tr>
884 <tr valign="top">
885 <td align="center">%u</td>
886 <td>(first) URI</td>
887 </tr>
889 <tr valign="top">
890 <td align="center">%U</td>
891 <td>space-separated list of selected URIs</td>
892 </tr>
894 <tr valign="top">
895 <td align="center">%w</td>
896 <td>(first) basename without the extension</td>
897 </tr>
899 <tr valign="top">
900 <td align="center">%W</td>
901 <td>space-separated list of basenames without their extension</td>
902 </tr>
904 <tr valign="top">
905 <td align="center">%x</td>
906 <td>(first) extension</td>
907 </tr>
909 <tr valign="top">
910 <td align="center">%X</td>
911 <td>space-separated list of extensions</td>
912 </tr>
914 <tr valign="top">
915 <td align="center">%%</td>
916 <td>the &laquo;&nbsp;%&nbsp;&raquo; character</td>
917 </tr>
919 </table>
921 <!-- ----------------------------------------------------------------------------- -->
923 <h2 id="level-zero">Appendix A. The level-zero case</h2>
926 Though not strictly an action or a menu definition, the level-zero issue might be easily solved by this specification. The implementation is free to implement it or not.
927 </p>
929 Ordering the elements which have to be displayed at the level-zero of the file manager context menu is just a particular case of a menu definition.
930 </p>
932 An implementation might define a <?php code( "level-zero.directory" ); ?> file, which would contain the ordered list of level zero items identified by their <i>desktop_file_id</i>.
933 </p>
935 The <?php code( "[Desktop Entry]" ); ?> section of this <?php code( "level-zero.directory" ); ?> file would so have only one of the following keys:
936 </p>
938 <table border="1">
939 <tr valign="top">
940 <td nowrap="nowrap"><b>Key</b></td>
941 <td><b>Description</b></td>
942 <td nowrap="nowrap"><b>Value type</b></td>
943 <td><b>Req&nbsp;?</b></td>
944 </tr>
946 <tr valign="top">
947 <td><?php code( "ItemsList" ); ?></td>
948 <td>Same signification as <a href="http://www.nautilus-actions.org/?q=node/377#itemslist">above</a><br />
949 </td>
950 <td>strings list</td>
951 <td>no</td>
952 </tr>
953 <!--
954     <tr valign="top">
955     <td><?php code( "GetItemsList" ); ?></td>
956     <td>Same signification as
957     <a href="http://www.nautilus-actions.org/?q=node/377#getitemslist">above</a><br />
958     </td>
959     <td>string</td>
960     <td>no</td>
961     </tr>
963 </table>
966 The <?php code( "level-zero.directory" ); ?> file may be searched for in <?php code( "XDG_DATA_DIRS/file-manager/actions" ); ?>. The first one found would be used.
967 </p>
969 Not finding a <?php code( "level-zero.directory" ); ?> file should not prevent actions or menus to be displayed. Instead, they just would be displayed in an unspecified, implementation-dependant, order.
970 </p>
972 The name "<?php code( "level-zero.directory" ); ?>" is chosen to not risk any collision with regular <?php desktop(); ?> files.
973 </p>
975 <!-- ----------------------------------------------------------------------------- -->
977 <h2 id="menu-rationales">Appendix B. Some rationales about menu definition</h2>
979 <h3>The KDE way</h3>
982 KDE defines the "<?php code( "X-KDE-Submenu" ); ?>" key. This key defines the label of a submenu the current action(s) should be included in. Order of the actions in this submenu is defined by the "<?php code( "Actions" ); ?>" key, though this might be altered by the "<?php code( "X-KDE-Priority" ); ?>" key. When several <?php desktop(); ?> files define the same submenu, actions are merged.
983 </p>
985 What are the advantages of this solution ?
986 </p>
987 <ul>
988 <li>It exists, and is widely used in KDE ServiceMenus.</li>
989 <li>This is a down-to-top, self-contained, approach where each action says in which submenu it whishes to be included in.</li>
990 </ul>
992 What are the inconvenients of this solution ?
993 </p>
994 <ul>
995 <li>It lacks of an <?php code( "Icon" ); ?> key associated to the submenu; though this certainly be added, the risk exists that several submenus with same label actually define different icons.</li>
996 <li>It lacks of a <?php code( "Tooltip" ); ?> key associated to the submenu (though... idem as above)</li>
997 <li>When several <?php desktop(); ?> files define the same submenu (<i>i.e.</i> the same label), a merge operation is done so that all actions are included in the same submenu. The order of the actions after such a merge operation is not defined.</li>
998 <li>There is no way to define the global order of the actions, when all <?php desktop(); ?> files have been dealt with.</li>
999 <li>As the menu is adressed at the action-level, one has to modifiy each action when he wants to reorganize his menus.</li>
1000 <li>Whether there is any menu or not, there is no way to define order of level-zero elements.</li>
1001 </ul>
1003 <h3>An alternate way</h3>
1006 As the menu may be seen as just a particular case of action, it appears logically that its definition may directly be derived from the action definition.
1007 </p>
1009 What are the advantages (over the KDE way) of using this definition ?
1010 </p>
1011 <ul>
1012 <li>User/sysadmin has full control on the order of the displayed items, and on the content of the submenus.</li>
1013 <li>Defining menus outside of the actions is a conceptual advantage; this let creators of actions do their work without having to wonder in which menu the action should go.</li>
1014 <li>There is no way for an action creator to decide himself if its action is <i>Important</i> or should be displayed at the <i>TopLevel</i>.</li>
1015 <li>Associated with <i>ad-hoc</i> conditions, we are able to define conditional menus, thus optimizing the building of the whole contextual menu.</li>
1016 <li>This is not XML ;-)</li>
1017 </ul>
1019 What are the inconvenients ?
1020 </p>
1021 <ul>
1022 <li>As a top-to-down approach, just dropping a new <?php desktop(); ?> file somewhere is not enough to get advantage of this; not referenced actions or submenus will just be displayed anywhere in the contextual menu.</li>
1023 </ul>
1025 <!-- ----------------------------------------------------------------------------- -->
1027 <h2 id="example-c">Appendix C. An example of an action</h2>
1030 In the following example, we define an "Open terminal here" action, which has three profiles. These profiles are thought to be able to open a suitable terminal in most situations. They are ordered, and so only the first profile whose conditions are met at runtime will be used in the file manager context menu.
1031 </p>
1033 <blockquote>
1034   <pre>
1035     [Desktop Entry]
1036     Name = Open terminal here
1037     Tooltip = Open a new terminal here
1038     Icon = terminal
1039     Profiles = on_folder; on_file; on_desktop;
1041     [X-Action-Profile on_folder]
1042     Name = open a terminal on the current folder or on the selected folder
1043     MimeTypes = inode/directory;
1044     # note that this means strictly less than 2, as the equal sign is part of the DES syntax
1045     SelectionCount = < 2
1046     Exec = gnome-terminal --working-directory=%d
1048     [X-Action-Profile on_file]
1049     Name = open a terminal in the folder which contains selected items
1050     MimeTypes = all/allfiles;
1051     Exec = gnome-terminal --working-directory=$(echo %D | cut -d' ' -f1)
1053     [X-Action-Profile on_desktop]
1054     Name = open a terminal of the desktop
1055     Schemes = x-nautilus-desktop;
1056     Exec = gnome-terminal --working-directory=~/Desktop
1057   </pre>
1058 </blockquote>
1061 Note that this is only an example of how an action may be defined in a <?php desktop(); ?> file. It has not been deeply tested, and there is most probably more efficient ways of opening a terminal somewhere...
1062 </p>
1064 <!-- ----------------------------------------------------------------------------- -->
1066 <h2 id="example-d">Appendix D. An example of a menu</h2>
1069 Say for the example that the action defined <a href="http://www.nautilus-actions.org/?q=node/377#example-c">in previous appendix</a> is saved as <?php code( "~/.local/share/file-manager/actions/open-terminal.desktop" ); ?> file.
1070 </p>
1072 et define a menu which will embed this action. We will so create a second <?php desktop(); ?> file, with following content:
1073 </p>
1075 <blockquote>
1076   <pre>
1077     [Desktop Entry]
1078     Type = Menu
1079     Name = Terminal menu
1080     Tooltip = Some actions on terminals
1081     Icon = terminal-group
1082     ItemsList = open-terminal;
1083   </pre>
1084 </blockquote>
1087 This may be saved, e.g. as <?php code( "~/.local/share/file-manager/actions/menu-terminal.desktop" ); ?> file.
1088 </p>
1090 <!-- ----------------------------------------------------------------------------- -->
1092 <h2 id="refs">References</h2>
1094 <ul>
1095 <li><a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">Desktop Entry Specification</a></li>
1096 <li><a href="http://standards.freedesktop.org/menu-spec/menu-spec-latest.html" target="_blank">Desktop Menu Specification</a></li>
1097 <li><a href="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html" target="_blank">XDG Base Directory Specification</a></li>
1098 <li><a href="http://developer.kde.org/documentation/tutorials/dot/servicemenus.html" target="_blank">Creating Konqueror Service Menus</a></li>
1099 <li><a href="http://www.krusader.org/handbook/useractions.html" target="_blank">Krusader UserActions</a></li>
1100 <li><a href="http://thunar.xfce.org/pwiki/documentation/custom_actions" target="_blank">Thunar Custom Actions</a></li>
1101 </ul>
1103 <!-- ----------------------------------------------------------------------------- -->
1105 <h2 id="contributors">Contributors</h2>
1107 <ul>
1108 <li>Jonas B&auml;hr</li>
1109 <li>David Faure</li>
1110 <li>Ted Gould</li>
1111 <li>Hong Jen Yee &laquo; PCMan &raquo;</li>
1112 <li>Michael Pyne</li>
1113 <li>Liam R. E. Quin</li>
1114 <li>Pierre Wieser</li>
1115 </ul>
1117 <!-- ----------------------------------------------------------------------------- -->
1119 <h2 id="changelog">ChangeLog</h2>
1121 <table border="1">
1122 <tr>
1123 <td align="center">Version</td>
1124 <td align="center">Date</td>
1125 <td>Changes</td>
1126 </tr>
1128 <tr>
1129 <td align="center">0.1-draft</td>
1130 <td align="center">2009-12-07</td>
1131 <td>Creation</td>
1132 </tr>
1134 <tr valign="top">
1135 <td align="center">0.2-draft</td>
1136 <td align="center">2009-12-17</td>
1137 <td>
1138 - Move syntax considerations to a new "Desktop file" section.<br />
1139 - Add "Managed objects" section.<br />
1140 - Add "Defining menus" section.<br />
1141 - Deal with level zero items.<br />
1142 - Define a separate "Conditions" section.<br />
1143 - Remove "Rationales" section, moving comments to the corresponding key description.<br />
1144 - Remove <?php code( "Type" ); ?> key<br />
1145 - Remove all <?php code( "X-Action-" ); ?> prefix of the key names.<br />
1146 - Add needed keys in order to provider equivalent functionalities to KDE service menus.<br />
1147 - Current and extensions keys have been merged in the same table.<br />
1148 </td>
1149 </tr>
1151 <tr valign="top">
1152 <td align="center">0.3-draft</td>
1153 <td align="center">2009-12-23</td>
1154 <td>
1155 - No more talk about &laquo; extending &raquo;, but rather of &laquo; deriving &raquo;.<br />
1156 - Replace &laquo;&nbsp;<a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">fds</a>&nbsp;&raquo; acronym with &laquo;&nbsp;<a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html" target="_blank">DES</a>&nbsp;&raquo;.<br />
1157 - More clearly notice what this specification specifies, and what it doesn't specify.<br />
1158 - Move the &laquo;&nbsp;level-zero&nbsp;&raquo; case to a specific <a href="http://www.nautilus-actions.org/?q=node/377#level-zero">appendix</a>, as not a main part of this specification.<br />
1159 - Move rationales about the menu description to a specific <a href="http://www.nautilus-actions.org/?q=node/377#menu-rationales">appendix</a>.<br />
1160 - <?php code( "Comment" ); ?> key is renamed as <?php code( "Tooltip" ); ?> in menu and action definitions.<br />
1161 - Add <?php code( "Description" ); ?>, <?php code( "SuggestedShortcut" ); ?> keys to menu and action definitions.<br />
1162 - Add <?php code( "Path" ); ?>, <?php code( "StartupNotify" ); ?>, <?php code( "StartupWMClass" ); ?>, <?php code( "ForEach" ); ?> keys to profile definition.<br />
1163 - Remove <?php code( "SelectionCount" ); ?> key.<br />
1164 - Define available parameters.<br />
1165 - Create <a href="http://www.nautilus-actions.org/?q=node/377#contributors">Contributors</a> chapter.<br />
1166 - Create <a href="http://www.nautilus-actions.org/?q=node/377#refs">References</a> chapter.<br />
1167 </td>
1168 </tr>
1170 <tr valign="top">
1171 <td align="center">0.4-draft</td>
1172 <td align="center">2010-01-07</td>
1173 <td>
1174 - Remove <?php code( "ToolbarSameLabel" ); ?> action property.<br />
1175 - Add <?php code( "ExecuteAs" ); ?> profile property.<br />
1176 - Restore <?php code( "SelectionCount" ); ?> condition.<br />
1177 - Add myself as a <a href="http://www.nautilus-actions.org/?q=node/377#contributors">contributor</a>.<br />
1178 - Add a link to <a href="http://www.nautilus-actions.org/?q=node/377#changelog">ChangeLog</a>.<br />
1179 - Fix some links.<br />
1180 </td>
1181 </tr>
1183 <tr valign="top">
1184 <td align="center">0.5-draft</td>
1185 <td align="center">2010-01-28</td>
1186 <td>
1187 - Setup a default value for <?php code( "Path" ); ?> parameter.<br />
1188 - Update <a href="http://www.nautilus-actions.org/?q=node/377#contributors">contributors</a>.<br />
1189 </td>
1190 </tr>
1192 <tr valign="top">
1193 <td align="center">0.6-draft</td>
1194 <td align="center">2010-02-03</td>
1195 <td>
1196 - Add <?php code( "Type" ); ?> key for distinguishing Actions from Menus.<br />
1197 - Specifies what to do with present, but not listed, profiles.<br />
1198 - Specifies defaults for <?php code( "TryExec" ); ?>, <?php code( "ShowIfRegistered" ); ?>, <?php code( "ShowIfTrue" ); ?>, <?php code( "ShowIfRunning" ); ?>, <?php code( "MimeTypes" ); ?>, <?php code( "SelectionCount" ); ?>, <?php code( "Schemes" ); ?>, <?php code( "Capabilities" ); ?> keys.<br />
1199 </td>
1200 </tr>
1202 <tr valign="top">
1203 <td align="center">0.7-draft</td>
1204 <td align="center">2010-03-01</td>
1205 <td>
1206 - Remove <?php code( "Minimized" ); ?> and <?php code( "Maximized" ); ?> from available <?php code( "ExecutionMode" ); ?> modes.<br />
1207 - Remove <?php code( "ForEach" ); ?> key<br />
1208 - <?php code( "Profiles" ); ?> and <?php code( "ItemsList" ); ?> become dynamic<br />
1209 - Remove <?php code( "GetItemsList" ); ?> key<br />
1210 - Change <?php code( "SelectionCount" ); ?> default from "<?php code( "*" ); ?>" to "<?php code( ">0" ); ?>"<br />
1211 - <?php code( "Folders" ); ?> elements may be negated<br />
1212 - Specify how to read a Conditions string list which contains both positive and negated elements<br />
1213 </td>
1215 <tr valign="top">
1216 <td align="center">0.8-draft</td>
1217 <td align="center">2010-03-18</td>
1218 <td>
1219 - Update the <?php code( "Profile" ); ?> and <?php code( "ItemsList" ); ?> keys description, describing their dynamic behavior.<br />
1220 - Update the <?php code( "Path" ); ?> key description, removing the word 'first'.<br />
1221 - Set the <?php code( "ItemsList" ); ?> key as requested.<br />
1222 - Specify the use of wildcards in <?php code( "MimeTypes" ); ?>, <?php code( "Basenames" ); ?> and <?php code( "Folders" ); ?> keys.<br />
1223 - The <?php code( "Folders" ); ?> key value is now defined as a list of paths.<br />
1224 - Update the <?php code( "Folders" ); ?> key description, describing SelectionCount-based behavior.<br />
1225 - More precisely describes parameters expansion against multiple selection.</br />
1226 - Create <a href="http://www.nautilus-actions.org/?q=node/377#example-c">Appendix C</a> with an example of an action.<br />
1227 - Specify the format of the <?php code( "SuggestedShortcut" ); ?> key.<br />
1228 - Change to ExtensionAction and ExtensionMenu the type of actions and menus.<br />
1229 </td>
1230 </tr>
1232 <tr valign="top">
1233 <td align="center">0.9-draft</td>
1234 <td align="center">2010-03-25</td>
1235 <td>
1236 - Define the <?php code( "TargetLocation" ); ?> key.<br />
1237 </td>
1238 </tr>
1240 <tr valign="top">
1241 <td align="center">0.10-draft</td>
1242 <td align="center">2010-03-29</td>
1243 <td>
1244 - <?php code( "Hidden" ); ?> and <?php code( "NoDisplay" ); ?> keys are moved to <?php code( "Desktop Entry" ); ?> group.<br />
1245 </td>
1246 </tr>
1248 <tr valign="top">
1249 <td align="center">0.11-draft</td>
1250 <td align="center">2010-04-15</td>
1251 <td>
1252 - Change back the <?php code( "Type" ); ?> of actions (resp. menus) to "<?php code( "Action" ); ?>" (resp. "<?php code( "Menu" ); ?>").<br />
1253 - Change the keyword "<?php code( "_SEPARATOR_" ); ?>" to "<?php code( "SEPARATOR" ); ?>".<br />
1254 - Add <a href="http://www.nautilus-actions.org/?q=node/377#example-d">Appendix D</a> with an example of a menu.<br />
1255 - Rename the "<?php code( "NoDisplay" ); ?>" keyword to "<?php code( "Enabled" ); ?>".<br />
1256 </td>
1257 </tr>
1259 <tr valign="top">
1260 <td align="center">0.12-draft</td>
1261 <td align="center">2010-06-15</td>
1262 <td>
1263 - Replace the "Same as DES" words by the exact relevant excerpt from DES, for <?php code( "Hidden" ); ?>, <?php code( "Exec" ); ?>, <?php code( "StartupNotify" ); ?>, <?php code( "StartupWMClass" ); ?>, <?php code( "OnlyShowIn/NotShowIn" ); ?> and <?php code( "TryExec" ); ?> keys.<br />
1264 - Change the <?php code( "Capabilities" ); ?>" default value from "<?php code( "*;" ); ?>" to the empty list.<br />
1265 - Specify that the <?php code( "Capabilities" ); ?>" conditions are ANDed.<br />
1266 </td>
1267 </tr>
1269 </table>