When a user right-click on a folder in Nautilus, a menu appears. I want to add more options in that menu. I am using Gnome 3.
Is there any other way to customize that menu with command line? Actually I am making a Linux software and I want that these these options should be added when user installs the software.
You might want to use a Nautilus script, which doesn't require any additional installation like for Nautilus Actions.
In order to do that :
~/.local/share/nautilus/scripts/
It will then appear under the Scripts entry, from the right click context menu like below:
This answer may be late, but it might be still useful.
Write your own script and put it to: ~/.local/share/nautilus/scripts/
An example might be more clear:
If you want to add a Context Menu like Open By VSCode
, you can create a file named OpenByVScode.sh
with the content:
#!/bin/bash
code -n ${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}
then, make it executable;
chmod 744 OpenByVScode.sh
Finally, cope/move this file to ~/.local/share/nautilus/scripts/
The Context Menu is ready to use, which will be displayed under script submenu.
First line: #!/bin/bash
, to specify which language interpreter needed
Second line: code -n ${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}
code
is the VSCode
default command, option -n
means force to open in new window, on the contrary, it also has other option like -r
, reuse the current windows, if the software is not open, this option will be the same like -n
. For more, please check by code --help
.
The variable NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
is defined by nautilus, like its name meaning, the path for the selected file or folder. It also has other three type of variables:
1. NAUTILUS_SCRIPT_SELECTED_URIS : newline-delimited URIs for selected files
2. NAUTILUS_SCRIPT_CURRENT_URI : current location
3. NAUTILUS_SCRIPT_WINDOW_GEOMETRY : position and size of current window
For more info, please refer HERE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With