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 4 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 # This script is executed (asynchronously) when you missed a call
# You can use it to play a ring tone # You can use it to play a ring tone
#we simply remove the ring trigger file # kill existing ring playback
#written by the ring hook and the ringing will stop MPVID="$(cat "$XDG_RUNTIME_DIR/sxmo.ring.pid")"
rm /tmp/ring.trigger 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 # This script is executed (asynchronously) when you pick up an incoming call
# remove the ring trigger # kill existing ring playback
rm /tmp/ring.trigger 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 # This script is executed (asynchronously) when you get an incoming call
# You can use it to play a ring tone # You can use it to play a ring tone
#vibrate the phone once # Start the mpv ring until another hook kill it
sxmo_vibratepine 2500 & 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 # Vibrate while mpv is running
#and ring for as long as it exists while kill -0 $MPVID; do
#the missed_call or pickedup hooks delete sxmo_vibratepine 1500
#delete this trigger again sleep 0.5
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
done done

Loading…
Cancel
Save