Este capítulo explica cómo personalizar ciertas partes del administrador de archivos a sus propias necesidades.
Thunar incluye un menú Enviar a, que proporciona posibes destinos donde los archivos y carpetas pueden ser enviados. Para acceder al menú Enviar a, seleccione → en el menú principal, o haga clic derecho en un fichero o carpeta y seleccione .
By default, the Send To menu includes an entry named Desktop (Create Link) for all
files and folders, which simply creates a link on the desktop for each selected file. In addition, if the Shortcuts
Pane is active, the menu also includes an entry called Side Pane (Create Shortcut) for folders,
which allows users to add new shortcuts to the side pane. Following these entries, Thunar
lists
the removable drives currently plugged into the computer. In the screenshot above, the Floppy Drive
represents a possible target where files can be sent to. Note that the device is mounted automatically once selected from
the Send To menu, so you do not need to manually mount it.
In addition Thunar
also ships the thunar-sendto-email
plugin, which adds
the entry Mail Recipient to the menu, that opens the mail composer with the selected files attach to the
new email. If the selection contains atleast one folder, the selected items are added to a ZIP archive before attaching them
to the email. Otherwise, if the selection contains multiple files, or a single file, which is larger than 200Kib, the user will
be prompted whether to pack the files into a ZIP archive, and send the ZIP archive.
Like most other features of Thunar
, the Send to menu can be easily extended
by users and application developers with new targets, using standard desktop entry files. These files must be
installed into one of the $XDG_DATA_DIRS/Thunar/sendto/
folders (see the XDG Base Directory Specification for details about the
$XDG_DATA_DIRS
variable).
The MimeType
of the target .desktop
specifies the types of files for which this action
should be available in the Send To menu. For example, say you want to add entry for a Flickr uploader tool, then this entry should only show up if the selection contains JPEG
files (other file formats are not supported by Flickr) and so you should add a line MimeType=image/jpeg;
.
If you do not specify any MimeType
your entry will show up for all file types.
A complete example using the postr
application is shown below:
# postr.desktop - Integrate postr into # the "Send To" menu. [Desktop Entry] Type=Application Version=1.0 Encoding=UTF-8 TryExec=postr Exec=postr %F Icon=postr Name=Flickr MimeType=image/jpeg;
If you install this file to ~/.local/share/Thunar/sendto/
(create the folder if
it does not exist yet), the Send To menu for JPEG files will show the new entry Flickr,
which can be used to upload JPEG images to Flickr.
The Thunar Project Wiki contains additional examples of useful targets for the Send To menu. Feel free to extend the Wiki page with new examples.
Thunar uses small utilities to create thumbnails of certain file types and displays the thumbnails as preview of the
file content. These small tools are called thumbnailers. Thunar ships with thumbnailers for image and font files, and
makes use of the installed thumbnailers from GNOME automatically if it was installed with support for gconf
.
Users may however dynamically extend this basic functionality with thumbnailers for additional file types.
If you plan to write a custom thumbnailers, you need to start with a program that accepts atleast two command line parameters, the input file, which is of the file type you plan to support and the output file, which is a PNG file that complies with the format specified by the Thumbnail Management Standard. Additionally your program may also accept the desired size of the thumbnail, which is optional but highly recommended. If you write the output file at an arbitrary image size, Thunar will afterwards scale it to the desired size, which might produce a less optimal result than generating the thumbnail with the requested dimensions.
Once your utility to generate the thumbnails is done, you will need to register your thumbnailer, so Thunar is able to locate
and use it. Therefore all you need to do is to install a description file for the thumbnailer (a .desktop
file)
in one of the $XDG_DATA_DIRS/thumbnailers/
paths. For example, if you want to register the
thumbnailer for your user account only, you can install the file into the folder ~/.local/share/thumbnailers/
. The .desktop
for thumbnailers has the following format.
Thumbnailer description files utilize the Desktop
Entry Format with a special Type
of X-Thumbnailer
and special field
X-Thumbnailer-Exec
with new field codes. Basically, a thumbnailer description file has the following format.
[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=X-Thumbnailer Name=Your Thumbnailer MimeType=your-supported/mime-type; X-Thumbnailer-Exec=your-thumbnailer %i %o %s
The Version
and Encoding
are mandated by the Desktop Entry Specification, just use the values shown
in the example above. The Type
field must have the special value X-Thumbnailer
, otherwise your
thumbnailer will not be recognized. The Name
value describes your thumbnailer.
The X-Thumbnailer-Exec
field contains the command to run your thumbnailer, and supports certain field codes that will
be substituted when the thumbnailer is run. Recognized field codes are as follows:
%i
%o
.png
, which matters if you invoke certain
third party tools.
%s
%u
%i
, but substituted with the URI of the file, rather than the path. This was added for compatibility with
GNOME.
%%
%
.
You need to include atleast %o
and %i
or %u
, otherwise your thumbnailer will
be useless.
The MimeType
lists the MIME types - separated by semicolon - for which your thumbnailer is able to create previews.
This example demonstrates how to write and install a new thumbnailer for .eps
files, which uses the
convert utility that ships as part of ImageMagick. First, we start with a simple script that invokes
convert to generate a thumbnail at the requested size.
#!/bin/sh # # eps-thumbnailer - Example thumbnailer script for EPS files. # # Usage: esp-thumbnailer eps-file png-file size # # command line parameters ifile=$1 ofile=$2 size=$3 # invoke convert (ImageMagick) exec convert "eps:$ifile" -scale "$sizex$size" "png:$ofile"
Save this script above to a file eps-thumbnailer
, make sure the file is executable and install it
to /usr/local/bin
.
$ chmod +x eps-thumbnailer $ sudo install eps-thumbnailer /usr/local/bin/eps-thumbnailer
Next we need to create the thumbnail description file eps-thumbnailer.desktop
, which looks like this:
[Desktop Entry] Version=1.0 Encoding=UTF-8 Type=X-Thumbnailer Name=EPS Thumbnailer TryExec=convert MimeType=image/x-eps; X-Thumbnailer-Exec=/usr/local/bin/eps-thumbnailer %i %o %s
This file must be installed to /usr/local/share/thumbnailers
(create the folder if
it does not exists).
$ sudo install -d /usr/local/share/thumbnailers $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbnailer.desktop
The eps-thumbnailer.desktop
file uses the special key TryExec
, which, if specified,
names a command that must be present on the system for the thumbnailer to be useful. In this case, our script is useless if
the convert utility is not present.
The last step is to regenerate the thumbnailer cache, so Thunar will pick up our thumbnailer. The thumbnailer cache is located
at $XDG_CACHE_HOME/Thunar/thumbnailers.cache
(unless overridden by your or your system administrator, the
$XDG_CACHE_HOME
points to the folder ~/.cache/
). The thumbnailers
cache is regenerated periodically by Thunar, but you can force to regenerate it by invoking the
thunar-vfs-update-thumbnailers-cache-1
utility, that ships as part of Thunar. This utility is usually installed
in the libexec
subfolder of your installation prefix (sbin
on Debian/Ubuntu). So for example, if Thunar is installed in /usr
, invoke the utility as
follows:
$ /usr/libexec/thunar-vfs-update-thumbnailers-cache-1
But make sure you run the program from your user account, not the superuser account, since the thumbnailers cache is stored in your home folder, rather than a system wide location.
Now, if Thunar is compiled with support for file alteration monitoring (using the FAM or Gamin services), it will automatically pick up the new thumbnailers cache within a few seconds and afterwards be able to generate thumbnails using your custom thumbnailers. Otherwise you might need to completely restart Thunar to apply the changes, using
$ Thunar -q
to terminate any running instance, and afterwards restart it from your launcher.
Las miniaturas generadas estan guardadas en el directorio ~/.thumbnails/
cumpliendo con el Thumbnail Management Standard. Cuando se testea un nuevo gestor de miniaturas, puede ayudar limpiar la caché usada
$ rm -rf ~/.thumbnails/
lo que además te dará algo de espacio libre en tu directorio home. Como toda la información guardada en este directorio es generada automaticamente con archivos de tu sistema, no perderás ningún dato importante.