[Thunar-dev] Trash script

Stefan Stuhr thunardevlist at sstuhr.dk
Mon Feb 20 22:44:38 CET 2006


Thunar doesn't have a trash like other file managers, and it doesn't
seem like it will get one in time for Thunar 1.0 (I do hope that I'm
wrong here). As I want to have a trash in my filemanager, I have
developed a simple trash script - simpletrash.sh (shell script with
embedded python code; attached to this mail) - with nice PyGTK dialogs,
that can be used to move files to a trash folder.

The script move files to ~/.Trash/ (which seems to be the same method
Nautilus uses) and append a number to the end of the filename (before
the extension) when there are name conflicts (e.g. file.txt >
file-2.txt). It uses the mv command, as that seems to work better than
the Python shutil.move method.

If one runs the script without arguments, ~/.Trash/ will be opened in
Thunar. Otherwise, the arguments are the files that one wants to move to
the trash.

The following suggestions expect the script to have the filename
simpletrash.sh, be executable, and in a directory in $PATH.

Suggestions for integration with Xfce and Thunar:
      * Add a launcher to a panel with the script as command. You can
        then drag-drop files from Thunar to the launcher to move them to
        the trash. If you click on the launcher, ~/.Trash/ will be
        opened in Thunar.
      * Give ~/.Trash/ a nice trash emblem in Thunar.
      * Add ~/.Trash/ to the shortcuts pane in Thunar and rename the
        shortcut to Trash (or what you want your trash folder to be
        called).
      * Add a custom action in Thunar with (but without quotes) Name:
        "Move to _Trash" and Command: "simpletrash.sh %F". Check all
        check boxes on the Appearance Conditions tab.
      * If and when Xfdesktop will get support for drag-dropping of
        files onto .desktop files as in Thunar (which executes
        the .desktop file's Exec with the dropped files as arguments),
        you can put the attached trash.desktop file in ~/Desktop/ and
        drop files onto it to move them to the trash.

Be aware that this script only supports ~/.Trash/ as trash folder, and
that files from other filesystems - removable media included - will be
moved to ~/.Trash/ if you uses this script with them as arguments. You
may not want to do that.

There is some (as in three) configuration options for the script, in the
top of the script after the GPL notice. One can configure the script not
to show the confirmation dialog or the error dialog.

Use this script at your own risk - any damage caused by this script
isn't in any way intentional.

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simpletrash.sh
Type: application/x-shellscript
Size: 6411 bytes
Desc: not available
URL: <http://mail.xfce.org/pipermail/thunar-dev/attachments/20060220/78cd6440/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trash.desktop
Type: application/x-desktop
Size: 318 bytes
Desc: not available
URL: <http://mail.xfce.org/pipermail/thunar-dev/attachments/20060220/78cd6440/attachment-0001.bin>


More information about the Thunar-dev mailing list