Xfce Forum

Sub domains
 

You are not logged in.

#26 2022-07-09 22:29:08

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

Hi ToZ, I did some tests:

 sleep 1 && ls -l ~/.local/share/Trash/files | wc -l
1

deleted a file:

 sleep 1 && ls -l ~/.local/share/Trash/files | wc -l
2

emptied trash:

 sleep 1 && ls -l ~/.local/share/Trash/files | wc -l
1

so it seems to be counting and working.

ls -l ~/.local/share/Trash/files
total 0

then deleted a file

 ls -l ~/.local/share/Trash/files
total 44
-rw-rw-r-- 1 shamu shamu 43327 Nov 20  2021 11.png

it sows 44 files?? I deleted only 1.
then emptied trash:

 ls -l ~/.local/share/Trash/files
total 0

And then:

 gio info Trash://
display name: Trash
name: /
type: directory
uri: trash:///
attributes:
  standard::type: 2
  standard::name: /
  standard::display-name: Trash
  standard::icon: user-trash, user-trash-symbolic
  standard::content-type: inode/directory
  standard::symbolic-icon: user-trash-symbolic, user-trash
  id::filesystem: trash:
  trash::item-count: 0

Now I should wait until the problem comes and run the test again


Linux Mint Xfce 21.1

Offline

#27 2022-07-09 22:35:52

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

Maybe try the other script, the one with inotifywait. It will only trigger when a file gets deleted and is not dependent on directory file counts.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#28 2022-07-09 23:03:48

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

I did. Installed inotify-tools, edited your script, after a reboot it did not play the sound.


Linux Mint Xfce 21.1

Offline

#29 2022-07-09 23:37:58

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

agashamu wrote:

I did. Installed inotify-tools, edited your script, after a reboot it did not play the sound.

Try running the script manually in a terminal window. See if that makes a difference.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#30 2022-07-09 23:45:01

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

I did "trash.sh" in the terminal,

trashsoundDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting.
shamu@shamu-p6710t:~$

Linux Mint Xfce 21.1

Offline

#31 2022-07-09 23:47:53

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

Is the other trash.sh instance running? If so, kill it and delete the /tmp/.trashsound.$USER.lockfile file. Then run the script again and test.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#32 2022-07-09 23:58:04

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

I moved the other file out of the way, how do I kill it? Uncheck in startup, reboot? Deleted temp file,

 trash.sh
trashsoundDEBUG: Locking succeeded

Last edited by agashamu (2022-07-10 00:01:32)


Linux Mint Xfce 21.1

Offline

#33 2022-07-10 00:08:29

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

agashamu wrote:

I moved the other file out of the way, how do I kill it? Uncheck in startup, reboot?

That would do it, yes.

Deleted temp file,

 trash.sh
trashsoundDEBUG: Locking succeeded

Is this the new script? If so, try your delete test again.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#34 2022-07-10 00:21:08

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

 sleep 1 && ls -l ~/.local/share/Trash/files | wc -l
1
1: command not found

Deleted a file

sleep 1 && ls -l ~/.local/share/Trash/files | wc -l
2

Emptied trash:

 sleep 1 && ls -l ~/.local/share/Trash/files | wc -l
1

Linux Mint Xfce 21.1

Offline

#35 2022-07-10 00:33:22

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

Did the sound play?

Edit: and if not, did you change the path and name of the sound file in the script?

Last edited by ToZ (2022-07-10 00:35:27)


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#36 2022-07-10 00:35:04

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

NO, it didn't


Linux Mint Xfce 21.1

Offline

#37 2022-07-10 00:35:53

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

agashamu wrote:

NO, it didn't

Can you post back the full contents of the script as you have it now?


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#38 2022-07-10 00:40:53

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

#!/bin/bash
# requires inotify-tools

DIR="$HOME/.local/share/Trash/files"

# make sure that only one instance of this script is running per user
lockfile=/tmp/.trashsound.$USER.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
   trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
   echo "trashsoundDEBUG: Locking succeeded" >&2

	inotifywait -q -m -r -e delete $DIR | while read D E F; do 
		play /home/shamu/My-sounds/trash-empty.wav
	done

# can't create lockfile - notify user and quit
else
   echo "trashsoundDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting." >&2
   exit 1
fi

Linux Mint Xfce 21.1

Offline

#39 2022-07-10 01:00:39

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

If you:

play /home/shamu/My-sounds/trash-empty.wav

...in a terminal window, does a sound play?

Can you also try this version of the script:

#!/bin/bash
# requires inotify-tools

echo "starting..." > /tmp/te.log
DIR="$HOME/.local/share/Trash/files"

# make sure that only one instance of this script is running per user
lockfile=/tmp/.trashsound.$USER.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
   trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
   echo "trashsoundDEBUG: Locking succeeded" >&2
echo "trap set" >> /tmp/te.log

	inotifywait -q -m -r -e delete $DIR | while read D E F; do 
		echo "caught delete - playing sound" >> /tmp/te.log
		play /home/shamu/My-sounds/trash-empty.wav
	done

# can't create lockfile - notify user and quit
else
   echo "trashsoundDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting." >&2
   exit 1
fi

Start it up, delete a file then empty trash, the post back the results of /tmp/te.log.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#40 2022-07-10 01:26:06

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

Sound plays in terminal.

deleted a file;

Emptied trash, no sound played.

/tmp/te.log:
starting...
trap set


ToZ, I don't want to hold you anymore tonight...Thank you so much!!!

Last edited by agashamu (2022-07-10 01:48:56)


Linux Mint Xfce 21.1

Offline

#41 2022-07-10 19:01:48

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

Hi ToZ, I'm sorry for keeping you for hours yesterday. You probably had other things to do, it's a little embarrassing...but it's a new day, if you have some more ideas, I'm gladly listening, thanks for all your help!


Linux Mint Xfce 21.1

Offline

#42 2022-07-10 19:26:12

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

No worries - I enjoy the challenges. Try this version of the script instead:

#!/bin/bash
# requires inotify-tools

DIR="$HOME/.local/share/Trash/info"

# make sure that only one instance of this script is running per user
lockfile=/tmp/.trashsound.$USER.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
   trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
   echo "trashsoundDEBUG: Locking succeeded" >&2

	inotifywait -q -m -r -e delete $DIR | while read D E F; do 
		play /home/shamu/My-sounds/trash-empty.wav
	done

# can't create lockfile - notify user and quit
else
   echo "trashsoundDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting." >&2
   exit 1
fi

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#43 2022-07-10 19:51:24

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

It WORKS!!!!! Plays the sound even fester then ever before!!! You did it again ToZ, I have said it before, but say it again: you ARE THE BEST!!!

ToZ wrote:

No worries - I enjoy the challenges.

You sure do! And you never give up! Thank you very much!


Linux Mint Xfce 21.1

Offline

#44 2022-07-10 20:47:39

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

ToZ, bad news. It stopped working again. Same as before.


Linux Mint Xfce 21.1

Offline

#45 2022-07-10 21:03:08

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

A couple of suggestions:
1. Change the play line to read:

play /home/shamu/My-sounds/trash-empty.wav >> /tmp/t.log 2>&1

...and try again. When it stops working, post back the contents of /tmp/t.log.
2. Try using another command instead of play - like mplayer.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#46 2022-07-10 22:24:59

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

I did try mplayer about a year ago, it didn't make any difference. I will try the play line trick. Thanks


Linux Mint Xfce 21.1

Offline

#47 2022-07-10 23:45:37

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

Changing that line didn't work. There is no  /tmp/t.log file. But there is a "config-err-mhuVFX" file, which is empty, I don't remember seeing it before but I could be wrong.



Sorry, I screwed up the line first. It does work now, and there is a /tmp/t.log file:

play WARN alsa: can't encode 0-bit Unknown or not applicable

/home/shamu/My-sounds/trash-empty.wav:

 File Size: 459k      Bit Rate: 1.41M
  Encoding: Signed PCM    
  Channels: 2 @ 16-bit   
Samplerate: 44100Hz      
Replaygain: off         
  Duration: 00:00:02.60  


In:0.00% 00:00:00.00 [00:00:02.60] Out:0     [      |      ]        Clip:0    
In:21.4% 00:00:00.56 [00:00:02.04] Out:24.6k [!=====|=====!]        Clip:0    
In:25.0% 00:00:00.65 [00:00:01.95] Out:28.7k [-=====|=====-] Hd:0.6 Clip:0    
In:28.6% 00:00:00.74 [00:00:01.86] Out:32.8k [ =====|===== ] Hd:0.6 Clip:0    
In:32.1% 00:00:00.84 [00:00:01.76] Out:36.9k [  ====|====  ] Hd:0.6 Clip:0    
In:39.3% 00:00:01.02 [00:00:01.58] Out:45.1k [   -==|==-   ] Hd:0.6 Clip:0    
In:42.9% 00:00:01.11 [00:00:01.49] Out:49.2k [    ==|=-    ] Hd:0.6 Clip:0    
In:46.4% 00:00:01.21 [00:00:01.39] Out:53.2k [    ==|==    ] Hd:0.6 Clip:0    
In:53.6% 00:00:01.39 [00:00:01.21] Out:61.4k [    -=|=-    ] Hd:0.6 Clip:0    
In:57.1% 00:00:01.49 [00:00:01.11] Out:65.5k [      |      ] Hd:0.6 Clip:0    
In:60.7% 00:00:01.58 [00:00:01.02] Out:69.6k [      |      ] Hd:0.6 Clip:0    
In:67.9% 00:00:01.76 [00:00:00.84] Out:77.8k [      |      ] Hd:0.6 Clip:0    
In:71.4% 00:00:01.86 [00:00:00.74] Out:81.9k [      |      ] Hd:0.6 Clip:0    
In:75.0% 00:00:01.95 [00:00:00.65] Out:86.0k [      |      ] Hd:0.6 Clip:0    
In:82.1% 00:00:02.14 [00:00:00.46] Out:94.2k [      |      ] Hd:0.6 Clip:0    
In:85.7% 00:00:02.23 [00:00:00.37] Out:98.3k [      |      ] Hd:0.6 Clip:0    
In:89.3% 00:00:02.32 [00:00:00.28] Out:102k  [      |      ] Hd:0.6 Clip:0    
In:96.4% 00:00:02.51 [00:00:00.09] Out:111k  [      |      ] Hd:0.6 Clip:0    
In:100%  00:00:02.60 [00:00:00.00] Out:115k  [      |      ] Hd:0.6 Clip:0    
In:100%  00:00:02.60 [00:00:00.00] Out:115k  [      |      ] Hd:0.6 Clip:0    
Done.
play WARN alsa: can't encode 0-bit Unknown or not applicable

/home/shamu/My-sounds/trash-empty.wav:

 File Size: 459k      Bit Rate: 1.41M
  Encoding: Signed PCM    
  Channels: 2 @ 16-bit   
Samplerate: 44100Hz      
Replaygain: off         
  Duration: 00:00:02.60  


In:0.00% 00:00:00.00 [00:00:02.60] Out:0     [      |      ]        Clip:0    
In:21.4% 00:00:00.56 [00:00:02.04] Out:24.6k [!=====|=====!]        Clip:0    
In:25.0% 00:00:00.65 [00:00:01.95] Out:28.7k [-=====|=====-] Hd:0.6 Clip:0    
In:28.6% 00:00:00.74 [00:00:01.86] Out:32.8k [ =====|===== ] Hd:0.6 Clip:0    
In:32.1% 00:00:00.84 [00:00:01.76] Out:36.9k [  ====|====  ] Hd:0.6 Clip:0    
In:39.3% 00:00:01.02 [00:00:01.58] Out:45.1k [   -==|==-   ] Hd:0.6 Clip:0    
In:42.9% 00:00:01.11 [00:00:01.49] Out:49.2k [    ==|=-    ] Hd:0.6 Clip:0    
In:46.4% 00:00:01.21 [00:00:01.39] Out:53.2k [    ==|==    ] Hd:0.6 Clip:0    
In:53.6% 00:00:01.39 [00:00:01.21] Out:61.4k [    -=|=-    ] Hd:0.6 Clip:0    
In:57.1% 00:00:01.49 [00:00:01.11] Out:65.5k [      |      ] Hd:0.6 Clip:0    
In:60.7% 00:00:01.58 [00:00:01.02] Out:69.6k [      |      ] Hd:0.6 Clip:0    
In:67.9% 00:00:01.76 [00:00:00.84] Out:77.8k [      |      ] Hd:0.6 Clip:0    
In:71.4% 00:00:01.86 [00:00:00.74] Out:81.9k [      |      ] Hd:0.6 Clip:0    
In:75.0% 00:00:01.95 [00:00:00.65] Out:86.0k [      |      ] Hd:0.6 Clip:0    
In:82.1% 00:00:02.14 [00:00:00.46] Out:94.2k [      |      ] Hd:0.6 Clip:0    
In:85.7% 00:00:02.23 [00:00:00.37] Out:98.3k [      |      ] Hd:0.6 Clip:0    
In:89.3% 00:00:02.32 [00:00:00.28] Out:102k  [      |      ] Hd:0.6 Clip:0    
In:96.4% 00:00:02.51 [00:00:00.09] Out:111k  [      |      ] Hd:0.6 Clip:0    
In:100%  00:00:02.60 [00:00:00.00] Out:115k  [      |      ] Hd:0.6 Clip:0    
In:100%  00:00:02.60 [00:00:00.00] Out:115k  [      |      ] Hd:0.6 Clip:0    
Done.

Last edited by agashamu (2022-07-11 00:04:49)


Linux Mint Xfce 21.1

Offline

#48 2022-07-11 02:14:59

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Empty Trash Can Sound[solved]

Another version to try. This one will also display a notification bubble when the sound should play. If the bubble shows up and the sound doesn't play, then its an issue with the sound:

#!/bin/bash
# requires inotify-tools

DIR="$HOME/.local/share/Trash/info"

# make sure that only one instance of this script is running per user
lockfile=/tmp/.trashsound.$USER.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
   trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
   echo "trashsoundDEBUG: Locking succeeded" >&2

	inotifywait -q -m -r -e delete $DIR | while read D E F; do 
		play /home/shamu/My-sounds/trash-empty.wav
                notify-send -i user-trash "Trash" "emtpy-trash sound should play"
	done

# can't create lockfile - notify user and quit
else
   echo "trashsoundDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting." >&2
   exit 1
fi

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#49 2022-07-11 02:31:32

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

Wow! Thanks! I will play with it. I'm running 2 distros on the same disk, Linux Lite and Mint Xfce. (cannot decide which one to keep permanently, they almost identical and running great) I will use one script in one and the other script in the other distro. We'll see what happens...we are getting somewhere...
Thanks ToZ, I will report back to you soon. Have a wonderful night!!!


Linux Mint Xfce 21.1

Offline

#50 2022-07-11 03:33:32

agashamu
Member
From: California
Registered: 2021-03-01
Posts: 136

Re: Empty Trash Can Sound[solved]

I'm still wondering what can cause a script to stop working after some time? Like you said ToZ, a script should run from start to end, forever. So what can it be??? Maybe KBar has some ideas, but he's been silent...I guess, this crazy "no sense" trash empty sound project is not his style...


Linux Mint Xfce 21.1

Offline

Board footer

Powered by FluxBB