5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 06:50:22 +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 ( import (
"github.com/wailsapp/wails/v3/pkg/application" "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 { type Plugin struct {
@ -28,16 +25,10 @@ func (p *Plugin) Name() string {
func (p *Plugin) Init(app *application.App) error { func (p *Plugin) Init(app *application.App) error {
p.app = app p.app = app
if runtime.GOOS == "darwin" { // OS specific initialiser
bundleID := mac.GetBundleID() err := p.init()
if bundleID == "" { if err != nil {
p.app.Log(&logger.Message{ return err
Level: "INFO",
Message: "Application is not in bundle. StartAtLogin will not work.",
})
p.disabled = true
return nil
}
} }
return nil return nil
} }

View File

@ -6,12 +6,26 @@ import (
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/samber/lo" "github.com/samber/lo"
"github.com/wailsapp/wails/v3/pkg/logger"
"github.com/wailsapp/wails/v3/pkg/mac"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings" "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 { func (p *Plugin) StartAtLogin(enabled bool) error {
if p.disabled { if p.disabled {
return nil 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
}