This repository has been archived by the owner on Apr 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.go
81 lines (63 loc) · 1.59 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
package main
import (
"os"
"runtime"
"strconv"
"github.com/diamondburned/gotk4-handy/pkg/handy"
"github.com/diamondburned/gotk4/pkg/glib/v2"
"github.com/diamondburned/gotk4/pkg/gtk/v3"
"github.com/diamondburned/gtkcord3/gtkcord"
"github.com/diamondburned/gtkcord3/gtkcord/components/logo"
"github.com/diamondburned/gtkcord3/gtkcord/components/window"
"github.com/diamondburned/gtkcord3/gtkcord/variables"
"github.com/diamondburned/gtkcord3/internal/keyring"
"github.com/diamondburned/gtkcord3/internal/log"
_ "embed"
// Profiler
"net/http"
_ "net/http/pprof"
)
var profile bool
//go:embed logo.png
var logoPNG []byte
func init() {
glib.LogUseDefaultLogger()
// flag.BoolVar(&profile, "prof", false, "Enable the profiler")
logo.PNG = logoPNG
// Set the right envs:
if css := os.Getenv("GTKCORD_CUSTOM_CSS"); css != "" {
window.CustomCSS = css
}
if w, _ := strconv.Atoi(os.Getenv("GTKCORD_MSGWIDTH")); w > 100 { // min 100
variables.MaxMessageWidth = w
}
if os.Getenv("GTKCORD_QUIET") == "0" {
log.Quiet = false
profile = true
}
}
func LoadKeyring() string {
if token := os.Getenv("TOKEN"); token != "" {
return token
}
return keyring.Get()
}
func main() {
a := gtk.NewApplication("com.github.diamondburned.gtkcord3", 0)
g := gtkcord.New(a)
a.ConnectStartup(func() {
handy.Init()
})
a.ConnectActivate(func() {
g.Activate()
g.ShowLogin(LoadKeyring())
})
a.Connect("shutdown", func() { g.Close() })
if profile {
runtime.SetBlockProfileRate(5000000) // 5ms
go http.ListenAndServe("localhost:6969", nil)
}
if sig := a.Run(os.Args); sig > 0 {
os.Exit(sig)
}
}