-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
56 lines (47 loc) · 832 Bytes
/
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
package main
import (
"fmt"
"os"
"os/exec"
"time"
libui "git.sr.ht/~sircmpwn/aerc/lib/ui"
)
func main() {
remoteDisplay, ok := os.LookupEnv("WAYLAND_DISPLAY")
if !ok {
panic("No WAYLAND_DISPLAY set")
}
var (
err error
path string
proxy *Proxy
)
for idx := 0; idx < 10; idx++ {
path = fmt.Sprintf("wlhax-%d", idx)
if proxy, err = NewProxy(path, remoteDisplay); err == nil {
break
}
}
if err != nil {
panic(err)
}
defer os.Remove(path)
go proxy.Run()
defer proxy.Close()
dash := NewDashboard(proxy)
if len(os.Args) > 1 {
cmd := exec.Command(os.Args[1], os.Args[2:]...)
cmd.Start()
}
ui, err := libui.Initialize(dash)
if err != nil {
panic(err)
}
defer ui.Close()
dash.OnExit(ui.Exit)
for !ui.ShouldExit() {
if !ui.Tick() {
time.Sleep(16 * time.Millisecond)
}
}
}