Archives For November 30, 1999

gnome shell

While the trash icon does not have ‘Add to Favorites‘ context menu option, here’s how to manually add a trash can icon to the left launcher in Ubuntu 18.04 Gnome Shell.

First see the result effect (in the picture, the left panel was replaced by Dash to Dock extension):

1. Open terminal either via Ctrl+Alt+T shortcut key, or by searching for ‘terminal’ from app launcher.

2. Run command to create and edit an empty file called trash.sh:

gedit ~/Documents/trash.sh

When the file opens, paste following lines and save it.

#!/bin/bash
icon=$HOME/.local/share/applications/trash.desktop

while getopts "red" opt; do
	case $opt in
    r)
	if [ "$(gio list trash://)" ]; then
		echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon=user-trash-full\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$HOME/Documents/trash.sh -e'\n' > $icon
	fi
	;;
    e)
	gio trash --empty && echo -e '[Desktop Entry]\nType=Application\nName=Trash\nComment=Trash\nIcon=user-trash\nExec=nautilus trash://\nCategories=Utility;\nActions=trash;\n\n[Desktop Action trash]\nName=Empty Trash\nExec='$HOME/Documents/trash.sh -e'\n' > $icon
	;;
    d)
	while sleep 5; do ($HOME/Documents/trash.sh -r &) ; done
	;;
  esac
done

3. Make the script file executable and run it via the 2 commands:

chmod +x ~/Documents/trash.sh

./Documents/trash.sh -e

4. Search for ‘trash’ in software launcher and select ‘Add to Favorites’ in its context menu.

5. Finally open Startup Applications, click Add to add a new startup app:

  • Type a name for the trash script.
  • Type command /home/YOUR_USER_NAME/Documents/trash.sh -d

Reboot Ubuntu, and the trash can icon will change when it’s empty or not empty.

via: ubuntuforums

The trash can icon is moved from left launcher to desktop icon since Ubuntu switched back to Gnome Desktop.

For those using files context menu or keyboard shortcut to delete file folders, and getting access to trash can via Files (nautilus file browser), the desktop icon is kinda useless and you may want to remove it.

You can easily remove (hide) the trash can desktop icon by doing following steps:

1. Open Ubuntu Software, search for and install Gnome Tweaks, a Gnome 3 desktop configuration tool.

2. Once installed, launch Gnome Tweaks and navigate to Desktop pane. There you can see the toggles to show or hide some desktop icons.

Simply turn off the toggle for Trash and enjoy!