-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
112 lines (103 loc) · 3 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package main
import (
"cattail/backend/consts"
"cattail/backend/services"
"context"
"embed"
"os"
"runtime"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
runtime2 "github.com/wailsapp/wails/v2/pkg/runtime"
)
//go:embed all:frontend/dist
var assets embed.FS
//go:embed build/appicon.png
var icon []byte
var version = "0.0.0"
func main() {
// Create an instance of the app structure
tailSvc := services.TailScaleService()
sysSvc := services.System()
prefSvc := services.Preferences()
prefSvc.SetAppVersion(version)
windowWidth, windowHeight, maximised := prefSvc.GetWindowSize()
windowStartState := options.Normal
if maximised {
windowStartState = options.Maximised
}
if runtime.GOOS == "linux" {
_ = os.Setenv("GDK_BACKEND", "x11")
}
// Create application with options
err := wails.Run(&options.App{
Title: "Cattail",
Width: windowWidth,
Height: windowHeight,
MinWidth: consts.DEFAULT_WINDOW_WIDTH,
MinHeight: consts.DEFAULT_WINDOW_HEIGHT,
MaxWidth: consts.DEFAULT_WINDOW_WIDTH,
MaxHeight: consts.DEFAULT_WINDOW_HEIGHT,
WindowStartState: windowStartState,
Frameless: runtime.GOOS != "darwin",
EnableDefaultContextMenu: true,
HideWindowOnClose: true,
DisableResize: true,
StartHidden: true,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: options.NewRGBA(27, 38, 54, 0),
OnStartup: func(ctx context.Context) {
sysSvc.Start(ctx, version)
tailSvc.Startup(ctx)
},
OnDomReady: func(ctx context.Context) {
x, y := prefSvc.GetWindowPosition(ctx)
runtime2.WindowSetPosition(ctx, x, y)
// runtime2.WindowShow(ctx)
},
OnBeforeClose: func(ctx context.Context) (prevent bool) {
x, y := runtime2.WindowGetPosition(ctx)
prefSvc.SaveWindowPosition(x, y)
return false
},
SingleInstanceLock: &options.SingleInstanceLock{
UniqueId: "db1301ad-7f4f-4814-a513-f068c93a617b",
OnSecondInstanceLaunch: tailSvc.OnSecondInstanceLaunch,
},
Bind: []interface{}{
sysSvc,
prefSvc,
tailSvc,
},
Mac: &mac.Options{
TitleBar: mac.TitleBarHiddenInset(),
About: &mac.AboutInfo{
Title: "Cattail " + version,
Message: "",
Icon: icon,
},
WebviewIsTransparent: false,
WindowIsTranslucent: true,
},
Windows: &windows.Options{
WebviewIsTransparent: true,
WindowIsTranslucent: true,
DisableFramelessWindowDecorations: true,
},
Linux: &linux.Options{
ProgramName: "Cattail",
Icon: icon,
WebviewGpuPolicy: linux.WebviewGpuPolicyOnDemand,
WindowIsTranslucent: true,
},
})
if err != nil {
println("Error:", err.Error())
}
}