diff --git a/README.md b/README.md index 2d5154a..61ae587 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,13 @@ On [Nix(OS)](https://nixos.org)/nix-darwin, run `nix build` (or add this repo to ### `[general]` -| Key | Type | Default | Description | -| ------------------ | ------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `manage_restic` | bool | `false` | **Windows only.** If restic is not found in PATH, automatically downloads and updates a self-managed restic binary daily from GitHub. | -| `notifications` | string | `"none"` | `"all"` (success + errors), `"errors"` (errors only), or `"none"` (silent) | -| `schedule_display` | string | `"description"` | `"description"` (human-readable, e.g. "every 6 hours"), `"cron"` (raw expression, e.g. "0 \* \* \* \*"), or `"none"` | -| `terminal` | string | `""` | Terminal emulator used in "Shell" and "View Log". If unset, MacOS will use `Terminal.app`. Linux will use default. Not used on Windows. e.g. "Ghostty" | +| Key | Type | Default | Description | +| ------------------ | ------ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `check_updates` | bool | `true` | **MacOS/Windows only.** Check for new Restray versions on startup and periodically. When an update is found, the version item in the menu changes to an update button | +| `manage_restic` | bool | `false` | **Windows only.** If restic is not found in PATH, automatically downloads and updates a self-managed restic binary daily from GitHub. | +| `notifications` | string | `"none"` | `"all"` (success + errors), `"errors"` (errors only), or `"none"` (silent) | +| `schedule_display` | string | `"description"` | `"description"` (human-readable, e.g. "every 6 hours"), `"cron"` (raw expression, e.g. "0 \* \* \* \*"), or `"none"` | +| `terminal` | string | `""` | Terminal emulator used in "Shell" and "View Log". If unset, MacOS will use `Terminal.app`. Linux will use default. Not used on Windows. e.g. "Ghostty" | ### `[[profile]]` diff --git a/cmd/restray/config.go b/cmd/restray/config.go index 4a7cf84..6e86b8a 100644 --- a/cmd/restray/config.go +++ b/cmd/restray/config.go @@ -64,12 +64,17 @@ type Profile struct { } type General struct { + CheckUpdates *bool `toml:"check_updates"` ManageRestic bool `toml:"manage_restic"` Notifications string `toml:"notifications"` ScheduleDisplay string `toml:"schedule_display"` Terminal string `toml:"terminal"` } +func (g General) UpdatesEnabled() bool { + return g.CheckUpdates == nil || *g.CheckUpdates +} + type Config struct { General General `toml:"general"` Profile []Profile `toml:"profile"` diff --git a/cmd/restray/templates/config.toml b/cmd/restray/templates/config.toml index 11b2ced..d8188aa 100644 --- a/cmd/restray/templates/config.toml +++ b/cmd/restray/templates/config.toml @@ -2,6 +2,7 @@ # Configuration reference: https://tangled.org/devins.page/restray#configuration [general] +# check_updates = true # manage_restic = false # notifications = "none" diff --git a/cmd/restray/tray.go b/cmd/restray/tray.go index abc0b37..944e7f6 100644 --- a/cmd/restray/tray.go +++ b/cmd/restray/tray.go @@ -191,8 +191,6 @@ func onReady() { mFolder := mConfigure.AddSubMenuItem("Open Folder", "Open folder in file manager") mAbout := mConfigure.AddSubMenuItem("Restray v"+version, "Open repository in browser") systray.AddSeparator() - mAppUpdate := systray.AddMenuItem("", "Download and install the latest version") - mAppUpdate.Hide() mQuit := systray.AddMenuItem("Quit", "Quit Restray") sched := cron.New() @@ -666,12 +664,14 @@ func onReady() { case <-mFolder.ClickedCh: openFile(configDir()) case <-mAbout.ClickedCh: - openFile("https://tangled.org/devins.page/restray") - case <-mAppUpdate.ClickedCh: - if v := latestKnownVersion.Load(); v != nil && applyUpdate(*v) { - sched.Stop() - stopAllMounts() - systray.Quit() + if v := latestKnownVersion.Load(); v != nil { + if applyUpdate(*v) { + sched.Stop() + stopAllMounts() + systray.Quit() + } + } else { + openFile("https://tangled.org/devins.page/restray") } case <-mQuit.ClickedCh: sched.Stop() @@ -681,7 +681,7 @@ func onReady() { } }() - if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { + if (runtime.GOOS == "windows" || runtime.GOOS == "darwin") && loadConfig().General.UpdatesEnabled() { go func() { check := func() { latest, err := latestVersion() @@ -691,8 +691,7 @@ func onReady() { } if compareVersion(latest, version) > 0 && artifactExists(artifactURL(latest)) { latestKnownVersion.Store(&latest) - mAppUpdate.SetTitle("Update to v" + latest) - mAppUpdate.Show() + mAbout.SetTitle("Update to v" + latest) } } check()