T1.6: Create src/platform/autostart; move autostart logic

Move autostart_*.go and tests from src/core to src/platform/autostart.
Update src/gui/app.go to call autostart.SetAutostart / autostart.AutostartStatus.
Add quoteDesktopExec to desktop_linux.go (was co-located in autostart_linux.go).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mixeme
2026-06-18 22:35:51 +03:00
parent 06edbfff77
commit 16d818d03d
8 changed files with 14 additions and 8 deletions
+5
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
)
func InstallDesktopIntegration(appID string, executablePath string, icon []byte) (string, error) {
@@ -40,6 +41,10 @@ StartupWMClass=%s
return iconPath, nil
}
func quoteDesktopExec(path string) string {
return strconv.Quote(path)
}
func xdgDataHome() (string, error) {
dataHome := os.Getenv("XDG_DATA_HOME")
if dataHome == "" {
+3 -2
View File
@@ -15,6 +15,7 @@ import (
"gitea.mixdep.ru/mix/gosentry/assets"
"gitea.mixdep.ru/mix/gosentry/src/core"
"gitea.mixdep.ru/mix/gosentry/src/domain"
"gitea.mixdep.ru/mix/gosentry/src/platform/autostart"
"gitea.mixdep.ru/mix/gosentry/src/runner"
"gitea.mixdep.ru/mix/gosentry/src/scheduler"
"gitea.mixdep.ru/mix/gosentry/src/storage"
@@ -910,7 +911,7 @@ func settingsView(w fyne.Window, store *storage.Store, jobs *[]job) fyne.CanvasO
startOnLogin.SetChecked(store.Config.StartOnLogin)
autostartStatus := widget.NewLabel("")
refreshAutostartStatus := func() {
ok, message := core.AutostartStatus(store.Config.StartOnLogin, store.Paths.ExecutablePath)
ok, message := autostart.AutostartStatus(store.Config.StartOnLogin, store.Paths.ExecutablePath)
if ok {
autostartStatus.SetText("OK: " + message)
return
@@ -975,7 +976,7 @@ func settingsView(w fyne.Window, store *storage.Store, jobs *[]job) fyne.CanvasO
settingsStatus.SetText("Save failed: " + err.Error())
return
}
if err := core.SetAutostart(store.Config.StartOnLogin, store.Paths.ExecutablePath, store.Paths.DesktopIcon); err != nil {
if err := autostart.SetAutostart(store.Config.StartOnLogin, store.Paths.ExecutablePath, store.Paths.DesktopIcon); err != nil {
refreshAutostartStatus()
settingsStatus.SetText("Saved, autostart failed: " + err.Error())
return
@@ -1,6 +1,6 @@
//go:build linux
package core
package autostart
import (
"fmt"
@@ -1,6 +1,6 @@
//go:build linux
package core
package autostart
import (
"os"
@@ -1,6 +1,6 @@
//go:build !windows && !linux
package core
package autostart
import "fmt"
@@ -1,4 +1,4 @@
package core
package autostart
import (
"fmt"
@@ -1,6 +1,6 @@
//go:build windows
package core
package autostart
import (
"os"