5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 05:11:29 +08:00

[v3] Update start_at_login plugin to allow better compilation on Linux

This commit is contained in:
Lea Anthony 2023-04-06 08:29:20 +10:00
parent 755e869fe7
commit a998465034
4 changed files with 34 additions and 13 deletions

View File

@ -2,9 +2,6 @@ package start_at_login
import (
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/logger"
"github.com/wailsapp/wails/v3/pkg/mac"
"runtime"
)
type Plugin struct {
@ -28,16 +25,10 @@ func (p *Plugin) Name() string {
func (p *Plugin) Init(app *application.App) error {
p.app = app
if runtime.GOOS == "darwin" {
bundleID := mac.GetBundleID()
if bundleID == "" {
p.app.Log(&logger.Message{
Level: "INFO",
Message: "Application is not in bundle. StartAtLogin will not work.",
})
p.disabled = true
return nil
}
// OS specific initialiser
err := p.init()
if err != nil {
return err
}
return nil
}

View File

@ -6,12 +6,26 @@ import (
"fmt"
"github.com/pkg/errors"
"github.com/samber/lo"
"github.com/wailsapp/wails/v3/pkg/logger"
"github.com/wailsapp/wails/v3/pkg/mac"
"os"
"os/exec"
"path/filepath"
"strings"
)
func (p *Plugin) init() error {
bundleID := mac.GetBundleID()
if bundleID == "" {
p.app.Log(&logger.Message{
Level: "INFO",
Message: "Application is not in bundle. StartAtLogin will not work.",
})
p.disabled = true
}
return nil
}
func (p *Plugin) StartAtLogin(enabled bool) error {
if p.disabled {
return nil

View File

@ -0,0 +1,8 @@
//go:build linux
package start_at_login
func (p *Plugin) init() error {
// TBD
return nil
}

View File

@ -0,0 +1,8 @@
//go:build windows
package start_at_login
func (p *Plugin) init() error {
// TBD
return nil
}