Start autostart launches in tray

Add a shared --start-in-tray argument that lets autostart start the scheduler and tray integration without opening the main window.

Write the argument into Windows Startup shortcuts and Linux XDG Autostart desktop entries, and verify existing autostart entries include it.

Keep manual launches unchanged and let a manual second launch reveal an already-running instance while duplicate autostart launches stay hidden.
This commit is contained in:
mixeme
2026-06-16 21:52:00 +03:00
parent 44f24ab3d8
commit b1fe8bd675
9 changed files with 99 additions and 20 deletions
+10 -4
View File
@@ -42,9 +42,9 @@ const singleInstanceShowCommand = "show"
type job = core.Job
type event = core.RunRecord
func Run() {
func Run(startInTray bool) {
started := time.Now()
instanceListener, primary := acquireSingleInstance()
instanceListener, primary := acquireSingleInstance(!startInTray)
if !primary {
return
}
@@ -62,6 +62,10 @@ func Run() {
w.Resize(fyne.NewSize(1120, 720))
w.SetContent(newMainView(w, started))
serveSingleInstance(instanceListener, w)
if startInTray {
a.Run()
return
}
w.ShowAndRun()
}
@@ -96,7 +100,7 @@ func configureSystemTray(a fyne.App, w fyne.Window) {
})
}
func acquireSingleInstance() (net.Listener, bool) {
func acquireSingleInstance(showExisting bool) (net.Listener, bool) {
listener, err := net.Listen("tcp", singleInstanceAddress)
if err == nil {
return listener, true
@@ -104,7 +108,9 @@ func acquireSingleInstance() (net.Listener, bool) {
connection, dialErr := net.DialTimeout("tcp", singleInstanceAddress, time.Second)
if dialErr == nil {
_, _ = io.WriteString(connection, singleInstanceShowCommand)
if showExisting {
_, _ = io.WriteString(connection, singleInstanceShowCommand)
}
_ = connection.Close()
return nil, false
}