Removing the Trash icon from desktop
Up to Ubuntu 18.10
Launch Terminal and run
gsettings set org.gnome.nautilus.desktop trash-icon-visible false
You may alternatively use GUI tools like dconf-Editor or (GNOME) Tweaks (see this for reference).
Ubuntu 19.04 and later
Disable the trash icon option from Extensions > Desktop Icon in Tweaks:
Alternatively, run the following command
gsettings set org.gnome.shell.extensions.desktop-icons show-trash false
Adding a Trash icon to the Ubuntu dock
Up to Ubuntu 19.04
Follow the steps below.
First install the trash-cli
package by running
sudo apt install trash-cli
Create a .desktop
file (say trash-in-dock.desktop
) in your ~/.local/share/applications/
directory.
Open the file with a text editor and add the following lines
[Desktop Entry]
Comment=Trash icon for Ubuntu dock
Terminal=false
Name=Trash for Dock
Exec=nautilus trash:///
Type=Application
Icon=user-trash
NoDisplay=false
Actions=empty-trash;
[Desktop Action empty-trash]
Name=Empty Trash
Exec=trash-empty
Save the file and re-login if needed.
Click "Activities" or press Super and search for Trash for Dock. It should appear in the results.
Right click the icon and select "Add to Favourites".
What you will get
A Trash icon in your dock, clicking which will open the Trash folder.
Right clicking the Trash icon in the dock will show an "Empty Trash" option which should work as intended.
What you won't get
The Trash icon in the dock would be like other app icons, it won't be conveniently placed at the bottom like in Unity Launcher.
The Trash icon in the dock would be a 'static' one, i.e. won't show two different icons depending on whether the Trash is empty or not.
Ubuntu 19.10 and later
Simply run the following command
gsettings set org.gnome.shell.extensions.dash-to-dock show-trash true
when the trash icon is changed by right clicking it, Properties and clicking on icon,
the path of this newly selected icon will be saved in ~/.config/nautilus/desktop-metadata
when the icon was not changed, some of the content in this file is
[trash]
nautilus-icon-position-timestamp=1551022571
nautilus-icon-position=56,146
icon-scale=1
for example:
I have changed the trash-icon by right clicking... then the content of above mentioned file changed to
[trash]
nautilus-icon-position-timestamp=1551022571
nautilus-icon-position=56,146
icon-scale=1
custom-icon=file:///home/pratap/Pictures/Screenshot%20from%202019-02-24%2021-09-32.png
to revert the changes..
the below line need to be deleted from the file ~/.config/nautilus/desktop-metadata
custom-icon=file:///home/pratap/Pictures/Screenshot%20from%202019-02-24%2021-09-32.png
to delete the line and save the changes..run the below command, edit and save the file.
sudo -H gedit ~/.config/nautilus/desktop-metadata
Now logout and login to see the change..
Best Answer
Up to Ubuntu 18.10
You may use (GNOME) Tweaks (aka GNOME Tweak Tool) to do that. First install it (if it is not installed) by running the following command in Terminal
or
Launch Tweaks and go to Desktop section. Then toggle off (or uncheck) the Trash (or Rubbish bin or Wastebasket) option under "Icons on Desktop".
Alternatively you may run the following command in Terminal: