I was getting tired of having to switch to command-line every time I was using the Nautilus file manager and wanted to do something that required superuser permissions. It was becoming a real limitation for me, but instead of just switching to another file manager (which usually means less seamless integration with the desktop environment) I looked into how I could extend Nautilus to do what I wanted it to do.
I came across the site http://g-scripts.sourceforge.net, which provides scripts that Nautilus can offer in it’s right-click menu. This is an amazing feature that really hasn’t been talked about nearly enough. You can essentially download or make a shell script that performs any actions on the directory that Nautilus has open, or files or directories that you have selected. You can get Nautilus to do anything from mounting an ISO, to changing the file permissions of a batch of files in a directory at once.
The script that helped me was http://g-scripts.sourceforge.net/nautilus-scripts/ Execute/Misc/root-nautilus-here. This script allowed me to right-click inside a directory window, and select an option I called “Open Root Window”, this requested my password, and opened a new Nautilus window in my current directory with superuser privileges. Exactly what I needed.
To add a script to Nautilus, you need to copy the script and paste it into a file inside the /home/[yourname]/.gnome2/nautilus-scripts/ directory. The name you give the file will become the name in the right-click menu, so make it a readable one. You can also put the scripts into sub-directories, which is useful if you end up with a lot of them. Once you have done that, you need to make it executable for your user. This could be done using the Right-click->Properties->Permissions in Nautilus, or via the command-line (chmod 700 ~/.gnome2/nautilus-scripts/[scriptname]).
That should be it! Right-click on a file and you should see your script appear in the “Scripts” sub-menu that appears.
If you decide to make any scripts, look to the G-Scripts site to help you get started. Often you can just tweak the scripts offered by the site to do what you want. Remember the script will be invisible, so use ” zenity –info –text=”debug text” ” commands throughout your script to debug it until everything works properly.