(inicio traducción) |
(→Enviar por correo el fichero seleccionado) |
||
| (No se muestran 7 ediciones intermedias realizadas por 2 usuarios) | |||
| Línea 30: | Línea 30: | ||
=== Dar derechos a tus scripts === | === Dar derechos a tus scripts === | ||
| − | {{Advertencia| Algunos scripts puede que necesiten ejecutarse como [[root]]; ésto generalmente es una mala idea, a menos que sepas qué estás haciendo. Se pueden configurar los permisos gracias al comando `chmod`. | + | {{Advertencia| Algunos scripts puede que necesiten ejecutarse como [[root]]; ésto generalmente es una mala idea, a menos que sepas qué estás haciendo. Se pueden configurar los permisos gracias al comando `chmod`.}} |
'''''CUIDADO-''''' 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.... | '''''CUIDADO-''''' 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.... | ||
| Línea 36: | Línea 36: | ||
== Scripting == | == Scripting == | ||
| − | == ¿Qué es un script? == | + | === ¿Qué es un script? === |
Puedes poner en nautilus una gran cantidad de "scripts", que pueden ser: | Puedes poner en nautilus una gran cantidad de "scripts", que pueden ser: | ||
* binarios (programas compilados) | * binarios (programas compilados) | ||
| Línea 44: | Línea 44: | ||
=== Variables de entorno === | === Variables de entorno === | ||
| − | Cuando un script es llamado, nautilus configura ciertas | + | Cuando un script es llamado, nautilus configura ciertas variables que pueden ser usadas en tus scripts. Estas son: |
* `NAUTILUS_SCRIPT_SELECTED_FILE_PATHS` | * `NAUTILUS_SCRIPT_SELECTED_FILE_PATHS` | ||
| Línea 53: | Línea 53: | ||
current location | current location | ||
* `NAUTILUS_SCRIPT_WINDOW_GEOMETRY` | * `NAUTILUS_SCRIPT_WINDOW_GEOMETRY` | ||
| − | position and size of current window | + | position and size of current window |
| − | + | ||
== Ejemplos de scripts == | == Ejemplos de scripts == | ||
| − | ''' | + | '''Nota: Estos scripts pueden estar desactualizados, utilízalos bajo tu propia responsabilidad''' |
| − | == Enviar por correo el fichero seleccionado == | + | === Enviar por correo el fichero seleccionado === |
Este script es realmente útil. ¿Cuanto tiempo se necesita para encontrar el fichero y enviarlo con [[Evolution]] o [[Thunderbird]]?. Es mucho más fácil usar nautilus para encontrar tu fichero y enviarlo desde ahí. | Este script es realmente útil. ¿Cuanto tiempo se necesita para encontrar el fichero y enviarlo con [[Evolution]] o [[Thunderbird]]?. Es mucho más fácil usar nautilus para encontrar tu fichero y enviarlo desde ahí. | ||
| Línea 67: | Línea 66: | ||
#!/usr/bin/perl -w | #!/usr/bin/perl -w | ||
# By John Russell | # By John Russell | ||
| − | + | ||
# This script sends the selected file(s) with your email client. | # This script sends the selected file(s) with your email client. | ||
| − | + | ||
use strict; | use strict; | ||
| − | + | ||
my $MAILTO_URL="mailto:?"; | my $MAILTO_URL="mailto:?"; | ||
my @files = split("\n", $ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}); | my @files = split("\n", $ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}); | ||
| Línea 89: | Línea 88: | ||
} | } | ||
} | } | ||
| − | + | ||
| − | + | ||
if ($count > 0) | if ($count > 0) | ||
{ | { | ||
| Línea 104: | Línea 103: | ||
# By John Russell | # By John Russell | ||
# and hacked to work with thunderbird by Darrell | # and hacked to work with thunderbird by Darrell | ||
| − | + | ||
# This script sends the selected file(s) with mozilla-thunderbird. | # This script sends the selected file(s) with mozilla-thunderbird. | ||
| − | + | ||
use strict; | use strict; | ||
| − | + | ||
my $attach_string="\"attachment='"; | my $attach_string="\"attachment='"; | ||
my @files = split("\n", $ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}); | my @files = split("\n", $ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}); | ||
| Línea 126: | Línea 125: | ||
} | } | ||
} | } | ||
| − | + | ||
| − | + | ||
if ($count > 0) | if ($count > 0) | ||
{ | { | ||
| Línea 138: | Línea 137: | ||
} | } | ||
| − | + | Verás que hay un script que se requiere, (~/scripts/thunderbird-email-attachments) en el ejemplo anterior, no lo pongas en el directorio de nautilus-scripts o sino se mostrará en el menú contextual: | |
| − | + | ||
#!/bin/sh | #!/bin/sh | ||
| − | + | ||
# if thunderbird is already running open a compose window in the running instance | # if thunderbird is already running open a compose window in the running instance | ||
| − | + | ||
| − | + | if `ps xc | grep -q mozilla-thunder`; then | |
| − | + | exec mozilla-thunderbird -a Mozilla-Thunderbird -remote "xfeDoCommand(ComposeMessage,$1)" | |
| − | + | ||
# else start a new instance with the compose window only | # else start a new instance with the compose window only | ||
| + | |||
| + | else | ||
| + | exec mozilla-thunderbird -compose $1 | ||
| + | fi | ||
| − | + | === Montar ISO === | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | == | + | |
| − | + | ||
| − | + | Montar una imagen ISO con nautilus. '''Nota para doc'''- este script se debe actualizar para que funcione con nombres de ficheros que contengan espacios (consultar fuente). | |
| − | |||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
| Línea 173: | Línea 169: | ||
done | done | ||
exit0 | exit0 | ||
| − | |||
| − | |||
| − | |||
| − | + | === Desmontar ISO === | |
| + | |||
| + | Desmontar una imagen ISO desde nautilus, from nautilus. '''Nota para doc'''- este script se debe actualizar para que funcione con nombres de ficheros que contengan espacios (consultar fuente). | ||
| − | |||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
| Línea 190: | Línea 184: | ||
done | done | ||
exit0 | exit0 | ||
| − | |||
| − | == | + | === Configurar fichero de solo lectura === |
| − | + | ||
| − | + | Cambiar permisos de fichero a solo lectura. | |
| − | |||
#!/bin/bash | #!/bin/bash | ||
| − | + | ||
chmod ugo-wx $* | chmod ugo-wx $* | ||
| − | |||
| − | |||
| − | |||
| − | + | === Editar fichero con [[Gedit]] y privilegios de root === | |
| + | |||
| + | '''Nota para doc'''- este script se debe actualizar para que funcione con nombres de ficheros que contengan espacios (consultar fuente). | ||
| − | |||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
| Línea 218: | Línea 207: | ||
done | done | ||
exit0 | exit0 | ||
| − | |||
| − | + | Otra alternativa más simple que funciona con ficheros que contienen espacios en el nombre: | |
| + | |||
| − | |||
#!/bin/sh | #!/bin/sh | ||
gksudo "gedit $NAUTILUS_SCRIPT_SELECTED_URIS" | gksudo "gedit $NAUTILUS_SCRIPT_SELECTED_URIS" | ||
| − | |||
| − | |||
| − | |||
| − | + | === Abrir Nautilus con privilegios de root aquí === | |
| + | |||
#!/bin/bash | #!/bin/bash | ||
# root-nautilus-here | # root-nautilus-here | ||
| Línea 249: | Línea 235: | ||
foo=`gksudo -u root -k -m "enter your password for nautilus root access" /bin/echo "got r00t?"` | foo=`gksudo -u root -k -m "enter your password for nautilus root access" /bin/echo "got r00t?"` | ||
sudo nautilus --no-desktop $NAUTILUS_SCRIPT_CURRENT_URI | sudo nautilus --no-desktop $NAUTILUS_SCRIPT_CURRENT_URI | ||
| − | |||
| − | + | Otra alternativa más simple: | |
| − | |||
#!/bin/sh | #!/bin/sh | ||
### root-nautilus-here | ### root-nautilus-here | ||
gksudo "nautilus --no-desktop $NAUTILUS_SCRIPT_CURRENT_URI" | gksudo "nautilus --no-desktop $NAUTILUS_SCRIPT_CURRENT_URI" | ||
| − | |||
| + | === Ejecutar ficheros con privilegios de root === | ||
| − | + | '''Nota para doc'''- este script se debe actualizar para que funcione con nombres de ficheros que contengan espacios (consultar fuente). | |
| − | + | ||
| − | |||
| − | |||
| − | |||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
| Línea 274: | Línea 254: | ||
done | done | ||
exit0 | exit0 | ||
| − | |||
| − | + | Otra alternativa más simple que funciona con ficheros que contienen espacios en el nombre y también abre directorios (en nautilus) como root: | |
| − | |||
#!/bin/sh | #!/bin/sh | ||
gksudo "gnome-open $NAUTILUS_SCRIPT_SELECTED_URIS" | gksudo "gnome-open $NAUTILUS_SCRIPT_SELECTED_URIS" | ||
| − | |||
| − | |||
| − | == | + | == Abrir ventana de búsqueda aquí == |
| − | + | ||
| − | |||
#!/bin/sh | #!/bin/sh | ||
# From Johnathan Bailes | # From Johnathan Bailes | ||
| Línea 299: | Línea 273: | ||
cd $NAUTILUS_SCRIPT_CURRENT_URI | cd $NAUTILUS_SCRIPT_CURRENT_URI | ||
exec gnome-search-tool | exec gnome-search-tool | ||
| − | |||
| − | == | + | == Abrir terminal aquí == |
| − | + | ||
| − | |||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
| Línea 342: | Línea 313: | ||
cd "$destination" | cd "$destination" | ||
exec x-terminal-emulator | exec x-terminal-emulator | ||
| − | |||
| − | == | + | === Esconder o mostrar ficheros ocultos === |
| − | + | ||
| − | |||
#!/bin/sh | #!/bin/sh | ||
# When hidden files (.emacs, etc) are hidden, shows "Show Hidden Files" option. | # When hidden files (.emacs, etc) are hidden, shows "Show Hidden Files" option. | ||
| Línea 362: | Línea 330: | ||
fi | fi | ||
gconftool-2 --set "/desktop/gnome/file_views/show_hidden_files" --type boolean $NEWSTATE | gconftool-2 --set "/desktop/gnome/file_views/show_hidden_files" --type boolean $NEWSTATE | ||
| − | |||
| − | |||
| − | + | Se puede hacer lo mismo sin scripts presionando <tt>CTRL+H</tt> en Nautilus | |
| − | + | ||
| − | = | + | == Enlaces útiles == |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| + | * http://g-scripts.sourceforge.net/ | ||
| + | * http://mundogeek.net/nautilus-scripts/ | ||
| + | == Ver también == | ||
| + | * [[Nautilus]] | ||
== Fuente== | == Fuente== | ||
* https://help.ubuntu.com/community/NautilusScriptsHowto | * https://help.ubuntu.com/community/NautilusScriptsHowto | ||
| + | |||
| + | <!-- Categorias--> | ||
| + | [[Categoría:Administradores de archivos]][[Categoría:Personalización]] | ||
El administrador de archivos nautilus es extensible a través del uso de scripts.
Con scripts puedes hacer muchas cosas, como por ejemplo:
Todo esto con un simple clic en el botón derecho del ratón
Contenido |
Todos tus scripts se almacenan en el directorio Nautilus-scripts - así que para añadir un nuevo script simplemente colócalo ahí. Puedes encontrar la carpeta Nautilus-scripts aquí :
~/.gnome2/nautilus-scripts
chmod +x nombre_de_script
O haz click con el botón derecho sobre el script y selecciona Propiedades, luego Permisos y dale permisos de ejecución.
¡Ya tienes tu script!
|
Algunos scripts puede que necesiten ejecutarse como root; ésto generalmente es una mala idea, a menos que sepas qué estás haciendo. Se pueden configurar los permisos gracias al comando `chmod`. |
CUIDADO- 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....
Puedes poner en nautilus una gran cantidad de "scripts", que pueden ser:
Es decir, básicamente cualquier cosa que se pueda ejecutar
Cuando un script es llamado, nautilus configura ciertas variables que pueden ser usadas en tus scripts. Estas son:
* `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
Nota: Estos scripts pueden estar desactualizados, utilízalos bajo tu propia responsabilidad
Este script es realmente útil. ¿Cuanto tiempo se necesita para encontrar el fichero y enviarlo con Evolution o Thunderbird?. Es mucho más fácil usar nautilus para encontrar tu fichero y enviarlo desde ahí.
#!/usr/bin/perl -w # By John Russell # This script sends the selected file(s) with your email client. use strict; my $MAILTO_URL="mailto:?"; my @files = split("\n", $ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}); my $count = 0; foreach my $file (@files) { if ( ! -f $file && ! -l $file ) { my @dialog = ("gdialog","--title","Error","--msgbox", "\nError: Can not send $file. \n\n Only regular files can be mailed. ","200", "300"); system (@dialog); } else { $MAILTO_URL = $MAILTO_URL . "attach=" . $file . "&"; shift; $count += 1; } } if ($count > 0) { my @command = ("gnome-open", $MAILTO_URL); system(@command); }
#!/usr/bin/perl -w
# By John Russell
# and hacked to work with thunderbird by Darrell
# This script sends the selected file(s) with mozilla-thunderbird.
use strict;
my $attach_string="\"attachment='";
my @files = split("\n", $ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS});
my $count = 0;
foreach my $file (@files)
{
if ( ! -f $file && ! -l $file )
{
my @dialog = ("gdialog","--title","Error","--msgbox", "\nError: Can not send $file. \n\n Only regular files can be mailed. ","200", "300");
system (@dialog);
}
else
{
$attach_string = $attach_string . "file://" . $file . ",";
shift;
$count += 1;
}
}
if ($count > 0)
{
$attach_string = $attach_string . "'\"";
# replace spaces with '%20' as demanded by mozilla/thunderbird
$attach_string =~ s/\s/%20/g;
# invoke shell script to call thunderbird differently depending on whether it's running already or not
my $command = ("~/scripts/thunderbird-email-attachments " . $attach_string);
system($command);
}
Verás que hay un script que se requiere, (~/scripts/thunderbird-email-attachments) en el ejemplo anterior, no lo pongas en el directorio de nautilus-scripts o sino se mostrará en el menú contextual:
#!/bin/sh # if thunderbird is already running open a compose window in the running instance if `ps xc | grep -q mozilla-thunder`; then exec mozilla-thunderbird -a Mozilla-Thunderbird -remote "xfeDoCommand(ComposeMessage,$1)" # else start a new instance with the compose window only else exec mozilla-thunderbird -compose $1 fi
Montar una imagen ISO con nautilus. Nota para doc- este script se debe actualizar para que funcione con nombres de ficheros que contengan espacios (consultar fuente).
#!/bin/bash
#
#By modprobing loop it makes sure that the module is loaded and ready for
#use. If it is already loaded then nothing will happen.
modprobe loop
for I in `echo $*`
do
foo=`gksudo -u root -k -m "enter your password for root terminal access" /bin/echo "got r00t?"`
sudo mount -o loop -t iso9660 $I /media/iso
done
done
exit0
Desmontar una imagen ISO desde nautilus, from nautilus. Nota para doc- este script se debe actualizar para que funcione con nombres de ficheros que contengan espacios (consultar fuente).
#!/bin/bash
#
for I in `echo $*`
do
foo=`gksudo -u root -k -m "enter your password for root terminal access" /bin/echo "got r00t?"`
sudo umount $I
done
done
exit0
Cambiar permisos de fichero a solo lectura.
#!/bin/bash chmod ugo-wx $*
Nota para doc- este script se debe actualizar para que funcione con nombres de ficheros que contengan espacios (consultar fuente).
#!/bin/bash
#
for I in `echo $*`
do
foo=`gksudo -u root -k -m "enter your password for root terminal access" /bin/echo "got r00t?"`
sudo gedit $I
done
done
exit0
Otra alternativa más simple que funciona con ficheros que contienen espacios en el nombre:
#!/bin/sh gksudo "gedit $NAUTILUS_SCRIPT_SELECTED_URIS"
#!/bin/bash # root-nautilus-here # opens a root-enabled instance of a nautilus window in selected location # requires sudo privileges and gksudo, which may involve security risks. #Install in your ~/Nautilus/scripts directory. # # Placed in the public domain by Shane T. Mueller 2001 # Fixes provided by Doug Nordwall # # 2004.04.18 -- keith@penguingurus.com - Added gksudo usage to provide popup # password window if sudo has expired. Line only echos got # root to std output. But gksudo updates your sudo access # privs, so running nautilus with sudo will succeed # without asking for a password. foo=`gksudo -u root -k -m "enter your password for nautilus root access" /bin/echo "got r00t?"` sudo nautilus --no-desktop $NAUTILUS_SCRIPT_CURRENT_URI
Otra alternativa más simple:
#!/bin/sh ### root-nautilus-here gksudo "nautilus --no-desktop $NAUTILUS_SCRIPT_CURRENT_URI"
Nota para doc- este script se debe actualizar para que funcione con nombres de ficheros que contengan espacios (consultar fuente).
#!/bin/bash
#
for I in `echo $*`
do
/usr/bin/gksudo $I
done
done
exit0
Otra alternativa más simple que funciona con ficheros que contienen espacios en el nombre y también abre directorios (en nautilus) como root:
#!/bin/sh gksudo "gnome-open $NAUTILUS_SCRIPT_SELECTED_URIS"
#!/bin/sh # From Johnathan Bailes # This script opens a gnome-search-tool in the directory you select. # # Distributed under the terms of GNU GPL version 2 or later # # Install in your ~/Nautilus/scripts directory. # You need to be running Nautilus 1.0.3+ to use scripts. cd $NAUTILUS_SCRIPT_CURRENT_URI exec gnome-search-tool
#!/bin/bash
#
# This script opens a gnome-terminal in the directory you select.
#
# Distributed under the terms of GNU GPL version 2 or later
#
# Install in ~/.gnome2/nautilus-scripts or ~/Nautilus/scripts
# You need to be running Nautilus 1.0.3+ to use scripts.
# When a directory is selected, go there. Otherwise go to current
# directory. If more than one directory is selected, show error.
if [ -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
set $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
if [ $# -eq 1 ]; then
destination="$1"
# Go to file's directory if it's a file
if [ ! -d "$destination" ]; then
destination="`dirname "$destination"`"
fi
else
zenity --error --title="Error - Open terminal here" \
--text="You can only select one directory."
exit 1
fi
else
destination="`echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed 's/^file:\/\///'`"
fi
# It's only possible to go to local directories
if [ -n "`echo "$destination" | grep '^[a-zA-Z0-9]\+:'`" ]; then
zenity --error --title="Error - Open terminal here" \
--text="Only local directories can be used."
exit 1
fi
cd "$destination"
exec x-terminal-emulator
#!/bin/sh
# When hidden files (.emacs, etc) are hidden, shows "Show Hidden Files" option.
# When hidden files are shown, shows "Hide Hidden Files" option.
# Uses gconf to toggle between the two Nautilus options.
# Should be placed in ~/.gnome2/nautilus-scripts/ with executable permission.
OLDSTATE=$(gconftool-2 --get "/desktop/gnome/file_views/show_hidden_files")
if [ "$OLDSTATE" == "false" ] ; then
NEWSTATE="True"
mv ~/.gnome2/nautilus-scripts/Show\ Dot\ Files ~/.gnome2/nautilus-scripts/Hide\ Dot\ Files
else
NEWSTATE="False"
mv ~/.gnome2/nautilus-scripts/Hide\ Dot\ Files ~/.gnome2/nautilus-scripts/Show\ Dot\ Files
fi
gconftool-2 --set "/desktop/gnome/file_views/show_hidden_files" --type boolean $NEWSTATE
Se puede hacer lo mismo sin scripts presionando CTRL+H en Nautilus