#!/bin/bash

while [ "$quit" != "y" ]
do
    clear

    echo "Make your selection"
    echo
    echo "[p]lay / pause"
    echo "[ijkl] moves cursor"
    echo "[r]everse"
    echo "[f]orward"
    echo "[h]ome"
    echo "[b]ack"
    echo "[s]elect"
    echo "i[n]fo"
    echo "ins[t]ant replay"
    echo "[e]xit"


    read command

    case "$command" in

	"P" | "p" )
	    echo
	    echo "play / pause"
	    command curl -d '' http://192.168.0.13:8060/keypress/play
	    ;;
	
	"E" | "e" )
	    echo
	    echo "are you sure you want to quit?"
	    echo "y confirms, all others return to menu."
	    read quit
	    ;;
	
	"H" | "h" )
	    echo
	    echo "home"
	    command curl -d '' http://192.168.0.13:8060/keypress/home
	    ;;

	"S" | "s" )
	    echo
	    echo "select"
	    command curl -d '' http://192.168.0.13:8060/keypress/select
	    ;;

	"B" | "b" )
	    echo
	    echo "back"
	    command curl -d '' http://192.168.0.13:8060/keypress/back
	    ;;

	"R" | "r" )
	    echo
	    echo "reverse"
	    command curl -d '' http://192.168.0.13:8060/keypress/rev
	    ;;

	"F" | "f" )
	    echo
	    echo "forward"
	    command curl -d '' http://192.168.0.13:8060/keypress/fwd
	    ;;

	"I" | "i" )
	    echo
	    echo "up"
	    command curl -d '' http://192.168.0.13:8060/keypress/up
	    ;;

	"K" | "k" )
	    echo
	    echo "down"
	    command curl -d '' http://192.168.0.13:8060/keypress/down
	    ;;

	"J" | "j" )
	    echo
	    echo "left"
	    command curl -d '' http://192.168.0.13:8060/keypress/left
	    ;;

	"L" | "l" )
	    echo
	    echo "right"
	    command curl -d '' http://192.168.0.13:8060/keypress/right
	    ;;

	"N" | "n" )
	    echo
	    echo "info"
	    command curl -d '' http://192.168.0.13:8060/keypress/info
	    ;;

	"T" | "t" )
	    echo
	    echo "instant replay"
	    command curl -d '' http://192.168.0.13:8060/keypress/instantreplay
	    ;;


	esac

done

echo

exit 0
