package main

import (
	"bufio"
	"fmt"
	"os"
	"time"

	"github.com/go-vgo/robotgo"
)

func jiggly() {
	time.Sleep(1 * time.Second)
	robotgo.MoveRelative(-10, 0)
	time.Sleep(250 * time.Millisecond)
	robotgo.MoveRelative(10, 0)
}

func doMouseStuff(tx chan bool) {
	for {
		select {
		case <-tx:
			return
		default:
			jiggly()
		}
	}
}

func main() {
	start := time.Now()
	ch := make(chan bool)
	go doMouseStuff(ch)
	fmt.Println("========== wiggly-jiggly ==============")
	fmt.Println("Press enter to exit.")
	reader := bufio.NewReader(os.Stdin)
	reader.ReadString('\n')
	ch <- true
	end := time.Now()
	fmt.Printf("Running for %s\n", end.Sub(start))
	fmt.Println("=============== bye! ===================")
}
