diff --git a/configs/default_hooks/missed_call b/configs/default_hooks/missed_call index 7c69d25..286748b 100644 --- a/configs/default_hooks/missed_call +++ b/configs/default_hooks/missed_call @@ -3,6 +3,7 @@ # This script is executed (asynchronously) when you missed a call # You can use it to play a ring tone -#we simply remove the ring trigger file -#written by the ring hook and the ringing will stop -rm /tmp/ring.trigger +# kill existing ring playback +MPVID="$(cat "$XDG_RUNTIME_DIR/sxmo.ring.pid")" +kill $MPVID +rm "$XDG_RUNTIME_DIR/sxmo.ring.pid" diff --git a/configs/default_hooks/pickup b/configs/default_hooks/pickup index 0cdc784..846ef76 100644 --- a/configs/default_hooks/pickup +++ b/configs/default_hooks/pickup @@ -2,8 +2,8 @@ # This script is executed (asynchronously) when you pick up an incoming call -# remove the ring trigger -rm /tmp/ring.trigger +# kill existing ring playback +MPVID="$(cat "$XDG_RUNTIME_DIR/sxmo.ring.pid")" +kill $MPVID +rm "$XDG_RUNTIME_DIR/sxmo.ring.pid" -# kill any existing playback -pkill mpv diff --git a/configs/default_hooks/ring b/configs/default_hooks/ring index 95e1104..d67b264 100644 --- a/configs/default_hooks/ring +++ b/configs/default_hooks/ring @@ -3,22 +3,13 @@ # This script is executed (asynchronously) when you get an incoming call # You can use it to play a ring tone -#vibrate the phone once -sxmo_vibratepine 2500 & +# Start the mpv ring until another hook kill it +mpv --quiet --no-video --loop /usr/share/sxmo/ring.ogg & +MPVID=$! +echo "$MPVID" > "$XDG_RUNTIME_DIR/sxmo.ring.pid" -#we create a temporary trigger file /tmp/ring.trigger -#and ring for as long as it exists -#the missed_call or pickedup hooks delete -#delete this trigger again -touch /tmp/ring.trigger -i=0 -while [ -f /tmp/ring.trigger ]; do - #play the ring over and over again as long as the trigger persists - #(you may want to replace this with a vibration) - mpv --quiet --no-video /usr/share/sxmo/ring.ogg - i=$((i+1)) - if [ $i -gt 10 ]; then - #safety check to protect against runaway endless ringing - rm /tmp/ring.trigger - fi +# Vibrate while mpv is running +while kill -0 $MPVID; do + sxmo_vibratepine 1500 + sleep 0.5 done