“UbuntuHelp:NautilusScriptsHowto”的版本间的差异
来自Ubuntu中文
小 |
小 |
||
(未显示同一用户的2个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/NautilusScriptsHowto}} | {{From|https://help.ubuntu.com/community/NautilusScriptsHowto}} | ||
{{Languages|UbuntuHelp:NautilusScriptsHowto}} | {{Languages|UbuntuHelp:NautilusScriptsHowto}} | ||
− | + | #title Nautilus Scripts Howto | |
+ | <<Include(Tag/ContentCleanup)>> | ||
+ | <<Anchor(Top)>> | ||
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNautilus.png | https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNautilus.png | ||
− | The | + | The Nautilus file manager is extensible through the use of scripts. |
== Introduction == | == Introduction == | ||
=== Purpose === | === Purpose === | ||
With scripts you can do many things such as : | 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 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 | * make a zip of a directory and mail it | ||
* open a terminal in the selected directory | * open a terminal in the selected directory | ||
* ... | * ... | ||
all of this with a simple right click. | all of this with a simple right click. | ||
− | [[Top Back to top]] | + | [[UbuntuHelp:[Top|Back to top]]] |
=== Managing Nautilus scripts === | === Managing Nautilus scripts === | ||
https://help.ubuntu.com/community/NautilusScriptsHowto?action=AttachFile&do=get&target=nautilus_folder.png | https://help.ubuntu.com/community/NautilusScriptsHowto?action=AttachFile&do=get&target=nautilus_folder.png | ||
− | All of your scripts are stored in the | + | 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: |
<pre><nowiki> | <pre><nowiki> | ||
~/.gnome2/nautilus-scripts | ~/.gnome2/nautilus-scripts | ||
</nowiki></pre> | </nowiki></pre> | ||
− | [[Top Back to top]] | + | [[UbuntuHelp:[Top|Back to top]]] |
==== Adding scripts ==== | ==== Adding scripts ==== | ||
− | * Open a text editor, copy/paste them into it, and save the script in | + | * 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 | * 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) | * 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) | ||
第27行: | 第29行: | ||
{i} You will not have a `File->Scripts` nor see a `Scripts` entry in the context menu until you first add files there | {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 ==== | ==== Removing scripts ==== | ||
− | + | Simply remove them from the `nautilus-scripts` folder. | |
==== Setting rights to your scripts ==== | ==== Setting rights to your scripts ==== | ||
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconWarning3.png | https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconWarning3.png | ||
− | You may need to run some scripts as a root user | + | 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.... | '''''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.... | ||
− | [[Top Back to top]] | + | [[UbuntuHelp:[Top|Back to top]]] |
== Scripting == | == Scripting == | ||
=== What is a script ? === | === What is a script ? === | ||
− | + | Scripts can be | |
* binaries (compiled programs) | * binaries (compiled programs) | ||
* shell scripts (bash, sh ...) | * shell scripts (bash, sh ...) | ||
* ... | * ... | ||
that is to say basically anything that can be run | that is to say basically anything that can be run | ||
− | [[Top Back to top]] | + | [[UbuntuHelp:[Top|Back to top]]] |
=== Environment variables === | === Environment variables === | ||
− | Whenever a script is called, | + | Whenever a script is called, Nautilus sets some variables that can be used in your scripts. These are: |
* `NAUTILUS_SCRIPT_SELECTED_FILE_PATHS` | * `NAUTILUS_SCRIPT_SELECTED_FILE_PATHS` | ||
newline-delimited paths for selected files (only if local) | newline-delimited paths for selected files (only if local) | ||
第51行: | 第53行: | ||
* `NAUTILUS_SCRIPT_WINDOW_GEOMETRY` | * `NAUTILUS_SCRIPT_WINDOW_GEOMETRY` | ||
position and size of current window | position and size of current window | ||
− | [[ | + | [[UbuntuHelp:[Top|Back to top]]] |
− | + | ---- | |
− | + | [[UbuntuHelp:NautilusScriptsHowto/SampleScripts|Sample Scripts]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | [[ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
---- | ---- | ||
− | |||
== Links == | == Links == | ||
− | * [[ | + | * [[UbuntuHelp:Nautilus_Scripts|Nautilus_Scripts]] |
* [http://g-scripts.sourceforge.net/] | * [http://g-scripts.sourceforge.net/] | ||
* [http://mundogeek.net/nautilus-scripts/] | * [http://mundogeek.net/nautilus-scripts/] | ||
− | [[category: | + | ---- |
+ | [[category:CategorySoftwareDefault]] [[category:Category]] Software | ||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2010年5月19日 (三) 23:42的最新版本
点击翻译: |
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