diff --git a/cmd/app/main.go b/cmd/app/main.go index 9503dad..16ae094 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -5,8 +5,12 @@ import ( "github.com/sonjek/mouse-stay-up/internal/tray" ) +const ( + GitRepo string = "https://github.com/sonjek/mouse-stay-up" +) + func main() { - mc := mouse.NewController() + mc := mouse.NewController(GitRepo) trayIcon := tray.NewTray(mc) trayIcon.Run() } diff --git a/internal/mouse/mouse.go b/internal/mouse/mouse.go index f2d766e..e76872e 100644 --- a/internal/mouse/mouse.go +++ b/internal/mouse/mouse.go @@ -9,13 +9,15 @@ import ( type Controller struct { Enabled bool + GitRepo string SleepInterval time.Duration LastX, LastY int } -func NewController() *Controller { +func NewController(gitRepo string) *Controller { return &Controller{ Enabled: true, + GitRepo: gitRepo, } } diff --git a/internal/tray/tray.go b/internal/tray/tray.go index c2cbef3..1354b0d 100644 --- a/internal/tray/tray.go +++ b/internal/tray/tray.go @@ -8,6 +8,7 @@ import ( "github.com/getlantern/systray" "github.com/sonjek/mouse-stay-up/internal/mouse" + "github.com/sonjek/mouse-stay-up/internal/utils" ) var ( @@ -61,6 +62,7 @@ func (t *Tray) onReady() { mDisable := systray.AddMenuItem("Disable", "Disable mouse movement") mInterval := systray.AddMenuItem("Sleep Interval", "Set mouse movement interval") systray.AddSeparator() + mAbout := systray.AddMenuItem("About", "Open GitHub repo") mExit := systray.AddMenuItem("Exit", "Exit the application") // Hide the enable option since it's already enabled by default @@ -101,6 +103,8 @@ func (t *Tray) onReady() { // When an interval item is clicked, update the sleep interval and checkmarks t.mouseController.SetSleepIntervalSec(interval) t.updateIntervalChecks(interval) + case <-mAbout.ClickedCh: + utils.OpenWebPage(t.mouseController.GitRepo) case <-mExit.ClickedCh: systray.Quit() return diff --git a/internal/utils/about.go b/internal/utils/about.go new file mode 100644 index 0000000..5461326 --- /dev/null +++ b/internal/utils/about.go @@ -0,0 +1,15 @@ +package utils + +import ( + "os/exec" + "runtime" +) + +func OpenWebPage(url string) { + switch runtime.GOOS { + case "darwin": + exec.Command("open", url).Start() + case "linux": + exec.Command("xdg-open", url).Start() + } +}