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
Ji I did the translation here for my language (Brazilian) and it was perfect.
Congratulations
Have never hear about a Brazilian language thou
Thanks you for tutorial, but can we replace the “show applications” button to Trash?
That’s not easy as “show applications” button is hard coded. Try Dash to Panel or Dash to Dock extension (both available in Ubuntu Software) to replace the left panel if you don’t like the button postion.
or you can use that :
native Trash gnome shell extension :
https://extensions.gnome.org/extension/48/trash/
Thanks a lot