As you may already know, Gnome Shell does not provide an option to add a trash can icon to its Dash. Dock extensions such as Ubuntu Dock, Dock to Panel or Dash to Panel do not provide this option, so Ubuntu forum user Kerry created a script This script can add a dynamic trash can icon in Ubuntu Dock (Gnome Shell). The script should work for most Docks, not just Ubuntu Dock (Dash to Dock/Dash to Panel, etc.), and the script also has a 30-second timer to check whether the trash can is empty and change the icon accordingly. You can also empty the trash can from the trash can icon context (right-click) menu.
How to add trash icon to Ubuntu Dock in Gnome Shell
1. Download the script from Ubuntu Forum (Trash.zip from post #16) Put it in your home folder and unzip it.
2. Run the script to install all necessary files. Make sure that the script and the two trash can icons are in the “Trash” folder in the home directory.
In general, I recommend that you check out the code used in this script and any other scripts you run on the system, and only run them if you have at least a basic understanding of their purpose.
To automatically create a script to automatically launch the file and its application desktop file (to display it in the “Activity”), open a terminal and navigate to
~/Trash (The location where the script content is extracted), then use
-s. You can do this by running the following command:
cd ~/Trash chmod +x trash.sh ./trash.sh -s
3. Log out and log in
Don’t just restart the session, because that’s not enough. The startup script needs to run, so you need to log out and log in again.
trash In the Gnome Shell event, then select
Add to Favorites Add it to Ubuntu Dock/Dash to Dock/Dash to Panel or any docking station you are using. If the trash can is full, the trash can icon should turn red; if the trash can is empty, the trash can icon should turn green. Please give it some time because it only checks every 30 seconds whether the garbage is empty or full.
Adjust trash icon script
Adjustment 1: Hide the trash folder in the main directory
The script needs
~/Trash The folder exists, otherwise it will be unusable (the path is hardcoded). If this bothers you,
~/Trash The folder is easily hidden, so the file manager will not show the folder. To do this, create a file called
.hidden (Start with a dot!) In your home folder, and in this file, add
Trash. In this way, the file manager will
~/Trash As a hidden folder, it is displayed only when you choose to display hidden files and folders. Method 2: Use the current icon theme trash can icon to change the hard-coded trash can icon
By default, the script uses custom hard-coded icons. If you want to use your icon theme for the trash can icon in the Dock, please open
trash.sh Use a text editor (such as Gedit) to write the script, and then replace:
And save the file. Within 30 seconds or less (this is how often the script checks whether the trash can is empty or full), the dock trash icon should use your current icon theme.
Thanks Kerry for your help script!