Nemo scripts are script files which are executed when run from the Scripts entry in the Nemo drop-down menu. When executed from a local folder, scripts will be passed the selected file names. When executed from a remote folder (e.g. a folder showing web or ftp content), scripts will be passed no parameters.
Location:
The location for Nemo scripts, as of 2017, is ~/.local/share/nemo/scripts. Any script placed in that location and made executable will be visible in the right-click drop down menu in Nemo.
Creating a new script:
We're going to create a new script that does something simple such as display system uptime. This is a simple script but will give users an idea of how to create their own scripts using different commands.
Step 1:
Open your favorite text editor and paste the below code into the text editor.
Code: Select all
#!/bin/sh
# Description: This Nemo script uses Zenity to display system uptime.
myuptime=$(uptime)
zenity --title "Uptime" --info --text "$myuptime"
Line 1 (required) - this is called a shebang, it tells the system how to execute the script
Line 2 (optional) - empty, for the sake of readability
Line 3 (optional) - a bash comment describing the purpose of the file
Line 4 (optional) - empty, for the sake of readability
Line 5 (required) - this declares the variable "myuptime" and assigns a value to it, this value is determined by the uptime command
Line 6 (optional) - empty, for the sake of readability
Line 7 (required) - this line runs the Zenity app and displays the value assigned to the variable "myuptime"
Step 2:
Save the file as ~/.local/share/nemo/scripts/Uptime
Step 3:
Now we need to make the Uptime script executable for it to appear in Nemo's right-click menu. Open a terminal, change directories to ~/.local/share/nemo/scripts and run the following command:
Code: Select all
chmod a+x Uptime
Open a new Nemo window and you should see a new entry in the right-click drop down menu entitled "Scripts" - this item will be old news for users who have been using Nemo Scripts. Inside that new Scripts menu there should be a new menu item entitled "Uptime". Click on that Uptime menu entry and Zenity should pop up to display system uptime. The Scripts menu is also available from the Desktop, as shown in the attached screenshot.
Conclusion:
This tutorial was written to show users how to create and run a Nemo script. Many of the things we do in a terminal can be done with a Nemo script, it's as simple as creating a new script and entering the proper commands to accomplish a particular task. For those who are new to Linux, I highly recommend reading a bash tutorial prior to creating your own scripts.