Simplify and prevent killing existing mpv instances

Instead of the trigger file and killing mpv, we loop the ring
indefinitely until killed. Maybe we should still got a guardrail but I
still never needed it (modemmonitor would trigger missed_call late or
later ?)

Signed-off-by: Stacy Harper <contact@stacyharper.net>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
master
Stacy Harper 3 years ago committed by Maarten van Gompel
parent 65270eaea8
commit df73a9af1c
  1. 7
      configs/default_hooks/missed_call
  2. 8
      configs/default_hooks/pickup
  3. 25
      configs/default_hooks/ring

@ -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"

@ -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

@ -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

Loading…
Cancel
Save