automatic-mouse-mover/cmd/main.go

56 lines
1.2 KiB
Go
Raw Normal View History

package main
import (
2019-03-28 19:52:25 +00:00
log "github.com/sirupsen/logrus"
"github.com/getlantern/systray"
2019-03-28 00:40:22 +00:00
"github.com/prashantgupta24/automatic-mouse-mover/assets/icon"
"github.com/prashantgupta24/automatic-mouse-mover/pkg/mousemover"
)
func main() {
systray.Run(onReady, onExit)
}
func onReady() {
go func() {
systray.SetIcon(icon.Data)
ammStart := systray.AddMenuItem("Start", "start the app")
ammStop := systray.AddMenuItem("Stop", "stop the app")
2019-03-28 19:52:25 +00:00
ammStop.Disable()
systray.AddSeparator()
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
// Sets the icon of a menu item. Only available on Mac.
//mQuit.SetIcon(icon.Data)
mouseMover := mousemover.GetInstance()
for {
select {
case <-ammStart.ClickedCh:
2019-03-28 19:52:25 +00:00
log.Infof("starting the app")
mouseMover.Start()
2019-03-28 19:52:25 +00:00
ammStart.Disable()
ammStop.Enable()
//notify.SendMessage("starting the app")
case <-ammStop.ClickedCh:
2019-03-28 19:52:25 +00:00
log.Infof("stopping the app")
ammStart.Enable()
ammStop.Disable()
mouseMover.Quit()
case <-mQuit.ClickedCh:
2019-03-28 19:52:25 +00:00
log.Infof("Requesting quit")
mouseMover.Quit()
systray.Quit()
return
}
}
}()
}
func onExit() {
// clean up here
2019-03-28 19:52:25 +00:00
log.Infof("Finished quitting")
}