I am fairly new to bash script even though I have some experience.
I am looking for my Raspberry Pi to detect my phone when it becomes available on the network, when it does so to play an audio clip, I have managed do this via the script below.
I have a problem, however, when my phone becomes available on the network, I do not want the audio to keep looping; I need it to play once and then stop playing the audio clip once it has already played. However, I do want the script to keep on running so it can detect the next time my phone becomes available on the network.
Maybe there is a better way of doing it, if there is I would love to hear your suggestions.
#!/bin/sh
if ping -c 10 192.168.1.4 &> /dev/null
then
kodi-send --action="PlayMedia(/storage/music/welcome.mp3)"
ping 192.168.1.4 &> /dev/null
else
./checkforerikphone.sh
fi