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:
parent
755e869fe7
commit
a998465034
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
8
v3/plugins/start_at_login/plugin_linux.go
Normal file
8
v3/plugins/start_at_login/plugin_linux.go
Normal file
@ -0,0 +1,8 @@
|
||||
//go:build linux
|
||||
|
||||
package start_at_login
|
||||
|
||||
func (p *Plugin) init() error {
|
||||
// TBD
|
||||
return nil
|
||||
}
|
8
v3/plugins/start_at_login/plugin_window.go
Normal file
8
v3/plugins/start_at_login/plugin_window.go
Normal file
@ -0,0 +1,8 @@
|
||||
//go:build windows
|
||||
|
||||
package start_at_login
|
||||
|
||||
func (p *Plugin) init() error {
|
||||
// TBD
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user