make sure you phone always gets the same ip address from your router
- Code: Select all
#!/bin/bash
# This Script is to ping a ip addres ( My mobile phone)
# and pause music when it fails to detect a host
# it is crude dirty and badly written any sugestions
# or criticism welcome
#
# Trevor Cockayne trevoml@gmail.com
count=2
weplay=0
wepause=0
for (( ; ; ))
do
count=$(ping -4 -c2 192.168.1.136 | grep 'received' | awk -F',' '{ print $2}' | awk '{ print $1}')
if [ $count -eq 0 ]; then
if [ $wepause -eq 0 ]; then
mpc pause > /dev/null 2>&1
let wepause=1
else
let weplay=0
fi
else
if [ $weplay -eq 0 ]; then
mpc play > /dev/null 2>&1
let weplay=1
else
let wepause=0
fi
fi
sleep 10
done