You are not logged in.
Pages: 1
Trying to find a way to play a short click sound while changing the volume via GUI in xfce.
I know I can set the keyboard shortcut to increase/decrease the volume by 5% and play the sound each time on keyboard combo.
Just for testing I downloaded a random small wav file http://soundbible.com/1705-Click2.html
Installed "pulseaudio-utils" and tried to do something like this:
#!/bin/bash
PLAY_FILE="/home/misko/Downloads/click2.wav"
x=0
pactl subscribe | grep --line-buffered "sink" | while read -r event type on sync num; do
((x++))
if [[ $x -eq 10 ]]; then
x=0
if [[ "$(ps -eo pid,cmd | grep "aplay $PLAY_FILE" | grep -v grep)" == "" ]]; then
sleep 0.1
aplay "$PLAY_FILE" 2>/dev/null &
fi
fi
done
It works pretty good with the pnmixer.
That is when changing volume via slider fast, but not while slowly moving the volume control slider.
Sometimes it plays, sometimes not, sometimes double playing. Also noticed that this activates when playing a youtube vdeo in firefox.
Is there a better way to sync playing the "click" with the volume slider?
Last edited by Misko_2083 (2018-05-29 17:30:19)
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline
@Misko, your code works well here (with the xfce4-pulseaudio-plugin). I don't get any of those issues that you do.
As for the youtube issue, I was getting the same (looks like youtube plays with the volume as a video loads). I grepped it out and they stopped:
if [[ "$(ps -eo pid,cmd | grep "aplay $PLAY_FILE" | grep -v grep)" == ""
]]; then
if [[ "$(wmctrl -l | grep -i youtube)" == "" ]]; then
sleep 0.1
aplay "$PLAY_FILE" 2>/dev/null &
fi
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
@ToZ thanks,
Seems like the pulseaudio plugin works, it's just pnmixer.
As for the youtube issue, I was getting the same (looks like youtube plays with the volume as a video loads). I grepped it out and they stopped:
That will do it. Thanks.
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline
Pages: 1
[ Generated in 0.007 seconds, 7 queries executed - Memory usage: 525.54 KiB (Peak: 531.68 KiB) ]