jpfleury / corbeille-spacefm

Trash plugin for SpaceFM compliant with the FreeDesktop.org Trash specification
GNU General Public License v3.0
11 stars 4 forks source link

Overview

Corbeille-SpaceFM ("Corbeille" is the French for "Trash can") is a plugin adding trash support in the file manager SpaceFM.

Corbeille-SpaceFM is compliant with the FreeDesktop.org Trash specification, so it's interoperable with other compliant implementations, that will be able to manage files moved to trash by Corbeille-SpaceFM, and vice versa. Tests were made with Thunar, Nautilus and Dolphin.

Corbeille-SpaceFM supports filenames containing any characters, for example newlines.

Also, Corbeille-SpaceFM was coded with speed in mind. It has multi-core support and can manage hundreds or thousands of files without suffering significant delays. See the section Details below for benchmarks.

Requirements

Special attention was given to have minimum requirements. It's written in Bash, and only a few external tools from the package coreutils are used (ls, mv, rm...), so it should work out-of-the-box for everyone. If not, read the message error displayed while using a command of the plugin.

Installation

The plugin is available in a few languages:

You can use the downloaded archive to install the plugin in SpaceFM. Instructions to install a plugin in SpaceFM are available in the SpaceFM manual. In short, you can:

From source code

An archive of Corbeille-SpaceFM can be built from the source code:

Possible values for $LANG are en (English), fr (French) and sv (Swedish). An archive will be created at the root of the directory. You can use it to install the plugin in SpaceFM.

Uninstallation

See instructions about uninstalling a plugin on the SpaceFM manual.

Usage

Corbeille-SpaceFM consists of 9 commands (available in the SpaceFM menu Plugins | Trash if installed with root protection). Note that there's no command confirmation dialog before proceeding to the selected action.

Details

Speed

Corbeille-SpaceFM was designed to be fast, even when handling a great number of files. Multi-core is supported, Bash built-in commands were favored as much as possible and subprocesses in loops were reduced to a strict minimum.

Here are benchmarks comparing Corbeille-SpaceFM with Thunar, the default file manager of Xfce (I chose Thunar because Xfce is the desktop environment I'm using). Each command handled 1000 plain text files and was run 5 times. Results are the average time in seconds.

The first benchmark was on a laptop with an Intel Core 2 Duo T9300 processor and 4 GiB of RAM. SpaceFM 0.7.3 and Thunar 1.2.3 were used on Xubuntu 11.10. Results are:

Corbeille-SpaceFM Thunar
Move to Trash 3 12
Delete Permanently 3 12
Restore 4 15
Empty Trash 1 1

The second benchmark was on a netbook with an Intel Atom N450 and 2 GiB of RAM. SpaceFM 0.7.3 and Thunar 1.2.3 were used on Ubuntu 11.10. Results are:

Corbeille-SpaceFM Thunar
Move to Trash 15 41
Delete Permanently 14 44
Restore 19 50
Empty Trash 10 6

Symbols used for file size

Corbeille-SpaceFM uses the conventional binary prefix meaning when displaying file size, i.e. power of 2, but with the new prefixes proposed to unambiguously differentiate binary prefixes from SI prefixes (power of 10). For example, MiB is used for 1024 KiB, and 1 KiB refers to 1024 bytes.

Trashable files

Files on the same device as the home trash are moved to this trash, i.e. $XDG_DATA_HOME/Trash. Most of the time, this will result to move files to /home/user/.local/share/Trash/files.

Files on other devices are not handled by Corbeille-SpaceFM, as allowed by the specification. Reasons are that such trashing is complex and, in my humble opinion, not very ergonomic.

According to the specification, files on other devices may be moved to the home trash. However, consider these situations:

An implementation may choose instead to support trashing in top directories, i.e. directly at the root of a mounted file system. However, consider the following:

Also, I consulted bug reports in Launchpad about trashing mechanism and found some interesting cases:

See for example this old (2005) bug report with 13 duplicates and 104 comments, Shouldn't put .Trash-$USER on removable devices, or this other one (2004), Ask to empty when unmounting media with items in trash, with 12 duplicates and 44 comments. Both are marked as fixed, but they're not. What we can observe is a lot of confusion from users and unclear implementations (or specification).

Personally, I would add that some file managers display files from top directory trashes directly in the home trash without any differentiation between them and the local ones. One may empty the home trash without knowing that it will also empty trashes located on other devices. One may want to empty a top directory trash without emptying the home trash, but find no way to accomplish this. One may also think that all files listed on the home trash are (logically) located on the home device, but after unmounting a removable device (and maybe sharing it), realize that some trashed files are no longer accessible (or, in other words, that the device still contains the trashed files). All of this is confusing.

I really think that the best way to handle trashing of files located on a different device is to let the user manage it manually. For example, one can manually move files to the home partition, then decide to move them to the home trash.

However, note that the Corbeille-SpaceFM command Go to Trash will display top directory trashes, if any, since the specification states:

If an implementation does NOT provide such trashing, and does provide the user with some interface to view and/or undelete trashed files, it SHOULD make a “best effort” to show files trashed in top directories (by both methods) to the user, among other trashed files or in a clearly accessible separate way.

Localization

Corbeille-SpaceFM is translatable:

Anyone interested can translate all strings and send me the result.

Development

Git is used for revision control. Repository can be browsed online or cloned.

License

Author: Jean-Philippe Fleury (http://www.jpfleury.net/en/contact.php)
Copyright © 2012 Jean-Philippe Fleury

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.