# Defining the conditions

Whether your action will eventually be displayed in &nautilus; file manager context menus or in its toolbar depends on the conditions you will have defined for it.

Conditions may be put against the location the file manager currently points to, or against the currently selected items in this location.

Each time the selection or the location change in the file manager, &prodname; checks all your actions, comparing the defined conditions against the new location and selection: all defined conditions must be satisfied in order your action be actually displayed.

## Basename-based conditions

You may decide that your action will appear depending on the basenames of the items currently selected in the file-manager: you may define that each item of the selection must meet some sort of basename, and you may simultaneously decide that none of the selected item(s) can have some other sort of basename.

Click on the Basenames tab to show the page which will permit you to configure your basename-based conditions.

### Basename-based conditions

Shows the tab which lets you define basename-based conditions.

The basename-based conditions tab

In fact, basename-based conditions are built as a list of &must_match; and &must_not_match; patterns. In order for your action to be a candidate regarding these basename-based conditions, each element of the selection must be valid for all the listed conditions: the basename of each element must match at least one of the defined &must_match; patterns, and must not match any of the defined &must_not_match; patterns.

If at least one element of the selection does not match all the defined conditions, then your action will not be displayed.

When targeting the selection context menu, your basename-based conditions will be checked against the currently selected items. When targeting the location context menu or the toolbar, your basename-based conditions will be checked against the basename of the current location.

Defining a new basename-based condition involves two steps.

1. Define the new condition filter.

   - Press Insert or click on button to insert a new condition filter

   - Edit the newly inserted condition filter to the basename you want match.

     A basename-based condition may use &asterisk; or &question_mark; wildcard characters.

2. Indicates whether this a &must_match; or a &must_not_match; condition.

   Click on the Must match one of or Must not match any of radio button in the same row to set the corresponding condition.

Depending of your target operating system, make sure that the Match case checkbox is activated (or not).

- When activated, all filters are considered as case sensitive, which means that `/my/file` filename is considered distinct from `/My/File` one.

  This is the default behavior on Unix-like systems.

- When deactivated, filters are considered as case insensitive, which means that `/my/file` and `/My/File` filenames are considered the same name.

  This is most probably what you want if you target some sort of &windows; system.

Removing a defined basename-based condition is as simple as selecting it, and pressing Del (or clicking on button).

By default, the basename-based condition is just one &laquosp;`must match one of *`&spraquo; condition. As all basenames always match the &asterisk; condition, this just means that basename-based conditions are not considered as relevant for the action.

## Mimetype-based conditions

You may decide that your action will appear depending on the mimetypes of the items currently selected in the file-manager: you may define that each item of the selection must meet some sort of mimetype; and you may simultaneously decide that none of the selected item(s) can have some other sort of mimetype.

Click on the Mimetypes tab to show the page which will permit you to configure your mimetype-based conditions.

### Mimetype-based conditions

Shows the tab which lets you define mimetype-based conditions.

The mimetype-based conditions tab

In fact, mimetype-based conditions are built as a list of &must_match; and &must_not_match; patterns. In order for your action to be a candidate regarding these mimetype-based conditions, each element of the selection must be valid for all the listed conditions: the mimetype of each element must match at least one of the defined &must_match; patterns, and must not match any of the defined &must_not_match; patterns.

If at least one element of the selection does not match all the defined conditions, then your action will not be displayed.

When targeting the selection context menu, your mimetype-based conditions will be checked against the currently selected items. When targeting the location context menu or the toolbar, your mimetype-based conditions will be checked against the mimetype of the current location, which happens to be the well known &laquosp;inode/directory&spraquo; mimetype.

Defining a new mimetype-based condition involves two steps.

1. Define the new condition filter.

   - Press Insert or click on button to insert a new condition filter

   - Edit the newly inserted condition filter to the mimetype you want match.

     A mimetype must be defined as a `group/subgroup` expression.

     The &asterisk; wildcard is supported only in some situations:

     - The &laquosp;`*/*`&spraquo; expression matches all mimetypes. As a convenient shortcut, the &asterisk; literal is also accepted for this same purpose.

     - A `group/*` string matches all subgroups of `group` mimetype.

     - The `*/subgroup` string is not accepted as a valid wildcard.

2. Indicates whether this a &must_match; or a &must_not_match; condition.

   Click on the Must match one of or Must not match any of radio button in the same row to set the corresponding condition.

Removing a defined mimetype-based condition is as simple as selecting it, and pressing Del (or clicking on button).

By default, the mimetype-based condition is just one &laquosp;`must match one of */*`&spraquo; condition. As all mimetypes always match the &laquosp;`*/*`&spraquo;, this just means that mimetypes are not considered as relevant for the action.

### Example of usual mimetypes

`all/all`

  Matches all items.

`all/allfiles`

  Matches all regular files.

`inode/directory`

  Matches only directories.

## Folder-based conditions

You may decide that your action will appear depending on the directory the items currently selected in the file-manager are located in: you may define that each item of the selection must be located in one hierarchy or in another; and you may simultaneously decide that none of the selected item(s) can be located in some other hierarchy.

A folder-based condition must be understood as the specification of the hierarchy in which the currently examined item should (or should not) stay: this is a pattern on the dirname of the element.

Click on the Folders tab to show the page which will permit you to configure your folder-based conditions.

### Folder-based conditions

Shows the tab which lets you define folder-based conditions.

The folder-based conditions tab

In fact, folder-based conditions are built as a list of &must_match; and &must_not_match; patterns. In order for your action to be a candidate regarding these folder-based conditions, each element of the selection must be valid for all the listed conditions: each element must be located in one of the defined &must_match; folders, and must not match any of the defined &must_not_match; folders.

If at least one element of the selection does not match all the defined conditions, then your action will not be displayed.

When targeting the selection context menu, your folder-based conditions will be checked against the dirname of each currently selected items. When targeting the location context menu or the toolbar, your folder-based conditions will be checked against the current location.

Defining a new folder-based condition involves two steps.

1. Define the new condition filter.

   - Press Insert or click on button to insert a new condition filter

   - Edit the newly inserted condition filter to the folder you want match.

     The &asterisk; and &question_mark; characters are accepted as wildcards at any level of the defined folder filter.

   - Or click on Browse to select a folder on the file system.

2. Indicates whether this a &must_match; or a &must_not_match; condition.

   Click on the Must match one of or Must not match any of radio button in the same row to set the corresponding condition.

Removing a defined folder-based condition is as simple as selecting it, and pressing Del (or clicking on button).

By default, the folder-based condition is just one &laquosp;`must match one of /`&spraquo; condition. As `/` is always the top of an Unix-like file system, then all selected items always match this condition.

If you target a &windows; system, then this default value may not be what you actually want.

## Scheme-base-conditions

You may decide that your action will appear depending on the schemes of the URIs of the items currently selected in the file-manager: you may define that each item of the selection must have some scheme; and you may simultaneously decide that none of the selected item(s) may have some other scheme.

Click on the Schemes tab to show the page which will permit you to configure your scheme-based conditions.

### Scheme-based conditions

Shows the tab which lets you define scheme-based conditions.

The scheme-based conditions tab

In fact, scheme-based conditions are built as a list of &must_match; and &must_not_match; patterns. In order for your action to be a candidate regarding these scheme-based conditions, each element of the selection must be valid for all the listed conditions: the scheme of each element must match at least one of the defined &must_match; patterns, and must not match any of the defined &must_not_match; patterns.

If at least one element of the selection does not match all the defined conditions, then your action will not be displayed.

When targeting the selection context menu, your scheme-based conditions will be checked against the currently selected items. When targeting the location context menu or the toolbar, your scheme-based conditions will be checked against the scheme of the current location.

Defining a new scheme-based condition involves two steps.

1. Define the new condition filter.

   - Press Insert or click on button to insert a new condition filter

   - Edit the newly inserted condition filter to the scheme you want match.

     Scheme-based conditions only accept &asterisk; wildcard, which stands for &laquosp;any scheme&spraquo;.

   - Or click on Common to select a scheme among those predefined in Edit Preferences .

     ### Selecting a scheme among predefined defaults

     Show the list of predefined schemes.

     Selecting a scheme among predefined defaults

     A new scheme may only be selected here if it is not already defined as a scheme filter.

     To select a new scheme, click OK, or double-click on the desired row.

2. Indicates whether this a &must_match; or a &must_not_match; condition.

   Click on the Must match one of or Must not match any of radio button in the same row to set the corresponding condition.

Removing a defined scheme-based condition is as simple as selecting it, and pressing Del (or clicking on button).

By default, the scheme-based condition is just one &laquosp;`must match one of *`&spraquo; condition, which means that schemes are not relevant for this action.

## Capability-based conditions

Capabilities are some properties that a file may exhibit to the user.

But except for the `Local` capability, all others depend on the user who executes the command.

You may so decide that your action will appear, or not, depending on the capabilities of the selected item(s) vs. the current user.

Click on the Capabilities tab to show the page which will permit you to configure your capability-based conditions.

### Capability-based conditions

Shows the tab which lets you define capability-based conditions.

The capability-based conditions tab

In fact, capability-based conditions are built as a list of &laquosp;must match all of&spraquo; and &must_not_match; patterns. In order for your action to be a candidate regarding these capability-based conditions, each element of the selection must be valid for all the listed conditions: the capability of each element must match each of the defined &laquosp;must match all of&spraquo; capabilities, and must not match any of the defined &must_not_match; ones.

If at least one element of the selection does not match all the defined conditions, then your action will not be displayed.

When targeting the selection context menu, your capability-based conditions will be checked against the currently selected items. When targeting the location context menu or the toolbar, your capability-based conditions will be checked against those of the current location.

Defining a new capability-based condition involves two steps.

1. Define the new condition filter.

   - Press Insert to insert a new condition filter.

   - Edit the newly inserted condition filter to the capability you want match.

   - Or click on to open the Adding a new capability dialog box.

     ### Managed capabilities

     Shows the list of managed capabilities.

     The list of managed capabilities

     A new capability may only be selected here if it is not already defined as a capability filter.

     To select a new capability, click OK, or double-click on the desired row.

2. Indicates whether this a &laquosp;must match all of&spraquo; or a &must_not_match; condition.

   Click on the Must match all of or Must not match any of radio button in the same row to set the corresponding condition.

Removing a defined capability-based condition is as simple as selecting it, and pressing Del (or clicking on button).

By default, the capability-based condition list is empty. This means that capabilities are not relevant for this action.

## Selection count condition

You may define that your action will only appear if the current selection in the file manager has some precise count, or some precise relation with a given count.

### A selection count use case

If your action consists in displaying the differences between two files, you may define here &laquosp;`Count = (equal to) 2`&spraquo;.

Click on the Environment tab to show the page which will permit you to configure your environment-based conditions.

### Environment-based conditions

Shows the tab which lets you define environment-based conditions. This includes the selection count configuration, the desktop selection, along with the runtime filters.

The environment-based conditions tab

The selection count condition is defined in the Appears if selection contains frame.

### Selection count condition frame

Focus on the Appears if selection contains frame.

Selection count condition frame

When targeting the selection context menu, the count condition defined here will be checked against the count of currently selected items. When targeting the location context menu or the toolbar, the count condition will be checked against zero because there is no selected item in this case.

To define a selection count condition:

- Select in the Count drop-down list the operator you want apply to the selection count:

  - `<` (strictly less than)
  - `=` (equal to)
  - `>` (strictly greater than)

- Enter the reference count you wish.

The selection count defaults to &laquosp;`Count > (strictly greater than) 0`&spraquo;, which means that the action will be a candidate to be displayed as soon as at least one item is selected in the file manager.

## Desktop selection

You may define that your action:

- will always appear,

- or will only appear in some given desktop environments,

- or will not appear in some given desktop environments.

Only one choice between these three items is possible.

Click on the Environment tab to show the page which will permit you to configure your environment-based conditions.

The desktop selection is defined in the Desktop environment frame.

### Desktop selection frame

Focus on the Desktop environment frame.

Desktop selection frame

To define the desktop environment condition:

1. First select the type of filter:

   - should your action always appear, regardless of the desktop environment ?
   - should your action only appear in some desktop environment(s) ?
   - should your action never appear in some desktop environment(s) ?

2. If your action should not always appear, then select the relevant desktop environment(s) in the listbox in the right side.

The targeted desktop environment condition defaults to &laquosp;`Always appear`&spraquo;, which means that the action will be a candidate to be displayed regardless of the current desktop environment.

## Executable found condition

You may define that your action will only appear if some prerequisite package is installed on your system. This is checked here by specifying that a specific file, known or at least supposed to be provided by the package, must be present on the file system, and executable.

Click on the Environment tab to show the page which will permit you to configure your environment-based conditions.

The executable found condition is defined in the Execution environment frame.

### Execution environment frame

Focus on the Execution environment frame.

Execution environment frame

To define the relevant file, enter its full filename in the Appears if the file is executable entry box, or click on Browse to select a file on the file system.

Leave the field empty if this condition is not relevant for your action.

You may embed some parameters in the searched filename. These parameters will be dynamically substituted at runtime with values which will depend on currently selected item(s).

## D-Bus registration condition

You may define that your action will only appear if some given name is registered on the D-Bus system at runtime.

Click on the Environment tab to show the page which will permit you to configure your environment-based conditions, and focus on Execution environment frame.

To define the relevant name, enter it in the Appears if the name is registered on D-Bus entry box.

Leave the field empty if this condition is not relevant for your action.

You may embed some parameters in the searched name. These parameters will be dynamically substituted at runtime with values which will depend on currently selected item(s).

## Customized condition

You may define that your action will only appear if some given command outputs a `true` string on its standard output.

Click on the Environment tab to show the page which will permit you to configure your environment-based conditions, and focus on Execution environment frame.

This lets you define your own customized condition filter, by writing a small script which outputs, or not, the `true` string on stdout when it is ran.

To define the command, enter it in the Appears if the command outputs "true" entry box.

Leave the field empty if this condition is not relevant for your action.

You may embed some parameters in the executed filename or its options. These parameters will be dynamically substituted at runtime with values which will depend on currently selected item(s).

## Running process condition

You may define that your action will only appear if some given binary is currently running.

Click on the Environment tab to show the page which will permit you to configure your environment-based conditions, and focus on Execution environment frame.

To define the binary, enter its name in the Appears if the binary is running entry box, or click on Browse to select a file on the file system.

Even if you enter here the full filename of a binary, only its basename will be searched for in the processes list at runtime.

Leave the field empty if this condition is not relevant for your action.

You may embed some parameters in the searched name. These parameters will be dynamically substituted at runtime with values which will depend on currently selected item(s).