Monday, February 26, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 4525  / 3 Years ago, sat, may 15, 2021, 5:33:13

Is there any way to add a sound event every time I empty the trash on my Ubuntu system?


More From » sound

 Answers
3

Empty Trash Sound Workaround



for Ubuntu 12.04.3



Maybe you will find my idea useful.
After 2 months of searching for a solution to get a trash-empty sound
in Ubuntu 12.04.3 I finally was able to put together something that works for me.
If anyone has an improved solution then please share.



You will note in the script below that I have chosen to use the "music123" app
which can be downloaded from the Ubuntu Software Centre and installed to the
/usr/bin folder. I got the idea from an article on how to set up Ubuntu shutdown sound --> from here.

That one worked great also, I even added the Ubuntu start-up sound.



The following script also uses the commands "trash-empty" and "trash-list".



These commands are part of the "trash-cli" command line utility which was also downloaded from the Ubuntu Software Centre.



Linux Script to Empty Trash with sound of glass breaking.



#!/bin/bash
#
# Name of script: empty-trash.sh
# script to empty trash with confirmation and empty trash sound event
# This script is located in /usr/local/bin

SOUND = "/usr/share/sounds/ubuntu/stereo/trash-empty.ogg"
trash-list > ~/.local/share/Trash/files/trash.lst
file = ~/.local/share/Trash/files/trash.lst

if [ ! -s $file ]; then

rm -f $file;
zenity --info --text "TRASH is EMPTY"

else

zenity --question --title "Confirm Yes/No" --text "EMPTY Trash Bin ?"

case $? in

0)
trash-empty;
/usr/bin/music123 $SOUND
;;

esac

fi


If you have a trash bin on the desktop or elsewhere, it will continue to work properly and it will still show the full and empty trash bin icons. If you do not want to hear the trash-empty sound then you can right-click on your regular trash bin icon and empty the trash in the usual way.
To empty the trash and hear your chosen sound click on the launcher made for that purpose. My trash-empty sound is that of breaking glass. You can choose whatever sound file you like, or make your own.



If you click on "Yes" in the zenity confirmation dialogue, then all the trash in all locations, including partitions and USB drives, will be emptied.



                                      ~.~


You can make an "Empty Trash" launcher and put it on your desktop to launch this script whenever you want to empty the trash. Make sure that you have made this script executable.
"Empty Trash" desktop script launcher



Attach a unique icon to the launcher. This is the one I used:
"Empty Trash" icon for the desktop script launcher



This is the Zenity dialogue question box to confirm emptying of trash:
Empty Trash confirmation zenity question box



This is the Zenity dialogue info box that appears if the trash bin is empty
and you have clicked on the "Empty-Trash" launcher.



Zenity empty trash info box



I added the above edit to provide the images that were not permitted during my initial post. I hope this extra information is useful.
- walt -wladicus 2013.12.30


[#29822] Sunday, May 16, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
njuash

Total Points: 402
Total Questions: 125
Total Answers: 98

Location: Jersey
Member since Sun, Dec 4, 2022
1 Year ago
;