LUbuntu 14.04 LTS - Add right click menu to Empty Trash



As a regular Lubuntu user, I really miss one simple thing that Gnome desktop provides out-of-the-box : a right menu on the desktop Trash to allow to directly empty it. Instead, you need to go to PcManFm and then you get a proper menu to empty the Trash !

Hopefully, thanks to latest version of PcManFm, it is now possible to customize some context-menu with your own actions. This means that we are now entitled to create a custom menu specific to the Trash object. This menu will do a simple thing : empty your trash with a dialog confirmation.

This article explains how to add this Empty trash menu to your desktop Trash icon under Lubuntu 14.04 LTS.

Original idea comes from this Ubuntuforums thread.

1. Install packages

Under Lubuntu, all trash files are stored under ~/.local/share/Trash/files.

To be able to easily empty the Trash thru command line, you need to install trash-empty command line utility that does the job.

This tool is provided by trash-cli package.

# sudo apt-get install trash-cli

2. Create custom action

With PcManFm, all custom actions are stored in ~/.local/share/file-manager/actions as standard .desktop files.

As this directory is not created by default, first step is to create it.

Then, the new custom action will be declared in ask-trash-empty.desktop. This file follows the standard .desktop format with a specific section [X-Action-Profile profile-zero] used by PcManFm.

Finally, the script that will do the real job of emptying the trash will be placed under /usr/local/bin/ask-trash-empty.

# mkdir --parents $HOME/.local/share/file-manager/actions
# wget -O $HOME/.local/share/file-manager/actions/ask-trash-empty.desktop
# sudo wget -O /usr/local/bin/ask-trash-empty
# sudo chmod +x /usr/local/bin/ask-trash-empty


[Desktop Entry]
Name[en_US]=Empty Trash
Name[en]=Empty Trash
Name[C]=Empty Trash
Name[fr_FR]=Vider la corbeille
[X-Action-Profile profile-zero]
Name[en_US]=Empty Trash
Name[en]=Empty Trash
Name[C]=Empty Trash
Name[fr_FR]=Vider la corbeille


# -------------------------------------------------------
#  Script used to empty trash from context menu 
#  Used in
#  01/11/2014, V1.0 - Creation by N. Bernaerts
# -------------------------------------------------------
# retrieve number of files in the trash
TRASH_QTY=`/usr/bin/trash-list | wc -l`
# ask for confirmation
[ "$TRASH_QTY" != "0" ] && zenity --question --title="" --text="Trash contains $TRASH_QTY items.\n\nDo you want to empty it ?"
# if answer is yes, empty trash
[ "$?" = "0" ] && /usr/bin/trash-empty

3. That's it

Everything is now ready.

You just need to close your session or to reboot your computer.

You should get a Empty trash menu right from your desktop Trash icon.

This menu will bring a confirmation dialog.



 Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus