Skip to content

Instantly share code, notes, and snippets.

@mtwebster
Last active December 8, 2023 18:45
Show Gist options
  • Save mtwebster/61814560062a8365481aff11f26039c1 to your computer and use it in GitHub Desktop.
Save mtwebster/61814560062a8365481aff11f26039c1 to your computer and use it in GitHub Desktop.

Actions

Actions enable you to add custom entries in Nemo's context menus.

At its most basic, an action can be defined by a single file.

Nemo Action File

  • An action file must end in .nemo_action
  • It can be placed in any data location under nemo/actions (for instance, /usr/share/nemo/actions, or ~/.local/share/nemo/actions). You should install user actions under your home folder.
The simplest action might have the following:
[Nemo Action]

Name=Start glxgears
Exec=glxgears
Selection=any
  • Name is the label for the action to display in the menu.
  • Exec is the command to be executed when the menu item is selected.
  • Selection allows you to set some basic selection criteria for showing the menu item. In this case, the menu item will always be visible in the context menu.

Tokens

Tokens allow you to insert additional information into certain fields based on the current selection.

Example:
[Nemo Action]
Name=Perform magic in %f
Exec=magic %F
Selection=single

Note the Selection field here is single, which causes this action to only be displayed if the current selection is of exactly one file.

  • The %f token in the Name field will be replaced by the selected file's display name (anything left of the final . in a filename). If you were to right click on file Mundania.txt, the menu item would be labeled Perform magic in Mundania.
  • The %F token in the Exec field will be replaced by the file's full path. Activating this action will result in magic /home/you/Mundania.txt being executed.
Full token list
Token Description
%U insert URI list of selection
%F insert path list of selection
%P insert path of parent (current) directory
%f insert display name of first selected file
%p insert display name of parent directory
%D insert device path of file (i.e. /dev/sdb1)
%e insert display name of first selected file with the extension stripped
%% insert a literal percent sign, don't treat the next character as a token
%X insert the XID for the NemoWindow this action is being activated in.
%N (deprecated) insert display name of first selected file - same as %f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment