ETA=$(cat /var/mobile/ETA)

if [ -e /var/mobile/killtimr ];
then
rm /var/mobile/killtimr
fi

while true
do
if [ -e /var/mobile/killtimr ];
then
rm /var/mobile/killtimr
break
fi
tiem=$(date +"%H:%M")
hourt=$(echo $tiem | cut -c1-2)
minutet=$(echo $tiem | cut -c4-5)
houreta=$(echo $ETA | cut -c1-2)
minuteeta=$(echo $ETA | cut -c4-5)

difh=$(expr $houreta - $hourt)
difm=$(expr $minuteeta - $minutet)

if [ $difh = 1 ];
then
h=hour
else
h=hours
fi
if [ $difm = 1 ];
then
m=minute
else
m=minutes
fi
b=0

if [ "$(echo $difh | cut -c1)" = "-" ];
then
b=1
echo "Time specified lies in the past. Aborting"
togo="The specified time lies in the past"
fi
if [ $(expr $minuteeta "<" $minutet) = 1 ] && [ $houreta = $hourt ];
then
echo "Time specified lies in the past. Aborting"
togo="The specified time lies in the past"
b=1
fi
if [ $(expr $minuteeta "<" $minutet) = 1 ] && [ $(expr $houreta ">=" $hourt) = 1 ];
then
difm=$(echo $difm | cut -d '-' -f2)
dat=$(expr $difh "*" 60 - $difm)
difm=$(expr $dat % 60)
difh=$(expr $dat / 60)
fi

###logisch2###
if [ $(expr $difh ">=" 0) = 1 ];
then
if [ $difh = 0 ];
then
togo="$difm $m to go"
 if [ $difm = 0 ];
 then
 togo="You should already have arrived by now."
 b=1
 fi
else
 if [ $difm = 0 ];
 then
 togo="$difh $h to go"
 else
 togo="$difh $h and $difm $m to go"
 fi
fi
else
echo "This point in time is already over"
togo="This point in time is already over"
b=1
fi
###/logisch2###
echo "\"ENABLING_SHUFFLE\" = \"shuffle on\";
\"GENIUS\" = \"playing genius playlist\";
\"GENIUS_NOT_AVAILABLE\" = \"$togo\";
\"GENIUS_TITLE_ARTIST_SPOKEN_FORMAT\" = \"playing genius playlist based on %@ by %@\";
\"GENIUS_TITLE_SPOKEN_FORMAT\" = \"playing genius playlist based on %@\";
\"IDENTIFY_SONG_TITLE_AND_ARTIST\" = \"now playing %@ by %@\";
\"MUSIC_ALREADY_PLAYING\" = \"Music is already playing.\";
\"NO_MUSIC\" = \"No music.\";
\"NO_MUSIC_PLAYING\" = \"No music is playing.\";
\"SELECT_ALBUM_ARTIST_SPOKEN_FORMAT\" = \"playing album %@ by %@\";
\"SELECT_ALBUM_SPOKEN_FORMAT\" = \"playing album %@\";
\"SELECT_ARTIST_SPOKEN_FORMAT\" = \"playing songs by %@\";
\"SELECT_PLAYLIST_SPOKEN_FORMAT\" = \"playing playlist %@\";
\"START_PLAYING_MUSIC_CONFIRMATION\" = \"No music is playing.  Do you want to play music now?\";
\"UNKNOWN_ARTIST\" = \"unknown artist\";
\"UNKNOWN_TITLE\" = \"untitled song\";" > /System/Library/VoiceServices/PlugIns/iPod.vsplugin/English.lproj/Feedback.strings
if [ $b = 1 ];
then
break
fi
sleep 3
done
