I am posting this in order to provide an answer, as a way to have a simpler method than using nautilus-actions
(launched with nautilus-actions-config-tool
), while avoiding to write each time an entire action file from scratch.
On the other, while nautilus-actions-config-tool
will not be used, nautilus-actions
has to be installed for the actions to appear in the context menu.
Best Answer
Reminder:
While with this solution the
nautilus-actions
will not be used in order to add the new context menu actions, it has to be installed for Nautilus to even have the actions feature at all, and for the actions to appear in the context menu.The idea is to have a ready-made but incomplete action file that is to be edited and saved under a new name for each new context menu action. This generic file can in turn be accessed each time with a launcher file (as if it were an app) or from the context menu itself (with another specific action file previously created).
Create the folder
~/.local/share/file-manager/actions
.To create the ready-made action file, do:
With these lines:
And save it.
That can be accessed directly of course, but it's nicer to have an easier way to open the ready-made file. This could be done through a launcher file:
With this content:
Making it executable:
After that it can be started from a menu or app launcher:
The above is meant to open the generic
~/.local/share/file-manager/actions/new-action.desktop
, edit, and save it with a different name.How to do it:
Run the launcher "New Nautilus action"
When the generic file is open in gedit, edit these lines that will define your new Nautilus menu action (that is: the menu name, the action-file name, and the command to execute):
#
before it) if you want the menu action to appear when you select files (of the types specified by the line MymeTypes; see below on the!
option). If you do not want it to appear on selection (a rare case when you want an action only to appear on empty area inside folders), remove the comment (#
).Considering the above line, if you do not want your new menu action to appear when you right-click an empty area, add
#
before it; remove the comment if you need the action to appear when you click an empty area inside folders.Add to the following line the mime-types of files for which your new action appears when you select them (remove/comment the line 'TargetContext=false' to achieve that):
Add the mime types like:
inode/directory
for folders,audio/*
for audio, etc to specify for which selection you want the action to appear; to exclude a certain mime type use!
before it. (For example: if you use an action to convert audio to mp3 you would want it to appear for all audio excepting mp3 files; in this case it should beMymeTypes=!audio/mp3;audio/*
.) Look in a file's properties (Basic/Type) in Nautilus to see its mime type.DO NOT SAVE THE FILE directly or your new action will overwrite the generic action file!
Use 'Save as' to save the file with a DIFFERENT NAME.