UbuntuHelp:NautilusScriptsHowto
来自Ubuntu中文
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
- title Nautilus Scripts Howto
<<Include(Tag/ContentCleanup)>> <<Anchor(Top)>> The Nautilus file manager is extensible through the use of scripts.
目录
Introduction
Purpose
With scripts you can do many things such as :
- make an enhanced "open with"-alike feature (open some files that match a filter in your preferred application)
- make a zip of a directory and mail it
- open a terminal in the selected directory
- ...
all of this with a simple right click. [[UbuntuHelp:[Top|Back to top]]]
Managing Nautilus scripts
All of your scripts are stored in the `nautilus-scripts` folder - so to add a new script, simply place it there. You can find the `nautilus-scripts` folder here:
~/.gnome2/nautilus-scripts
[[UbuntuHelp:[Top|Back to top]]]
Adding scripts
- Open a text editor, copy/paste them into it, and save the script in your `nautilus-scripts` folder
- name them accordingly to the label you want in the right-click context menu
- make them executable (`chmod +x my_script_name`, or right-click on the script, select properties, then permissions, and give allow it to be executable)
That's it! {i} You will not have a `File->Scripts` nor see a `Scripts` entry in the context menu until you first add files there
Removing scripts
Simply remove them from the `nautilus-scripts` folder.
Setting rights to your scripts
You may need to run some scripts as a root user. This is generally a bad idea, unless you know what you are doing. Setting appropriate rights can be done thanks to the `chmod` command. CAUTION- you might want to set the preferences in Nautilus/Gedit/Whatever_else_you_are_opening_as_root so as to let you know instantly whether or not you are currently in the root-application. i.e. a yellow background in root-gedit and nautilus, instead of the normal white.... [[UbuntuHelp:[Top|Back to top]]]
Scripting
What is a script ?
Scripts can be
- binaries (compiled programs)
- shell scripts (bash, sh ...)
- ...
that is to say basically anything that can be run [[UbuntuHelp:[Top|Back to top]]]
Environment variables
Whenever a script is called, Nautilus sets some variables that can be used in your scripts. These are:
- `NAUTILUS_SCRIPT_SELECTED_FILE_PATHS`
newline-delimited paths for selected files (only if local)
- `NAUTILUS_SCRIPT_SELECTED_URIS`
newline-delimited URIs for selected files
- `NAUTILUS_SCRIPT_CURRENT_URI`
current location
- `NAUTILUS_SCRIPT_WINDOW_GEOMETRY`
position and size of current window [[UbuntuHelp:[Top|Back to top]]]
Links
Software