You are not logged in.
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
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
I did. Installed inotify-tools, edited your script, after a reboot it did not play the sound.
Linux Mint Xfce 21.1
Offline
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
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
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
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
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
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
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
NO, it didn't
Linux Mint Xfce 21.1
Offline
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
#!/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
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
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
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
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
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!!!
No worries - I enjoy the challenges.
You sure do! And you never give up! Thank you very much!
Linux Mint Xfce 21.1
Offline
ToZ, bad news. It stopped working again. Same as before.
Linux Mint Xfce 21.1
Offline
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
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
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
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
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
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
[ Generated in 0.014 seconds, 8 queries executed - Memory usage: 653.35 KiB (Peak: 686.2 KiB) ]