#!/bin/bash

thresh=200;
tfile=~/mylocation
nfile=~/yourehere

olddis=`cat $tfile`

dis=$( ssh home "cd latitude_location; php currentlocation.php" )
#dis is the command to be run to get current distance to target. In this case php was not supported on the computer that ran the script so I had to ssh to a computer that did run php.
echo $dis>$tfile

t=$(echo $olddis \> $thresh \&\& $dis \< $thresh | bc)
if [ $t == 1 ]
then
echo "You're Here!" > $nfile
mplayer ~/Desktop/valkyries.ogg >/dev/null 2>&1
#mplayer ~/Desktop/jaws.wav >/dev/null 2>&1
#echo "You're here!" > /tmp/rubbish && DISPLAY=:0.0 nohup gedit /tmp/rubbish >/dev/null 2>&1 &
fi

t=$( echo $dis \> $thresh \&\& $olddis \< $thresh | bc )
if [ $t == 1 ]
then
echo "You're not here - get to work you lazy bugger" > $nfile
fi

