-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
63 lines (52 loc) · 1.05 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
package main
import (
"encoding/json"
"fmt"
"sync"
"time"
)
var config Config
var mu sync.Mutex
func draw() {
listJson := ""
for i := 0; i < len(config.Modules); i++ {
if config.Modules[i].Text == "" {
continue
}
moduleJson, err := json.Marshal(config.Modules[i])
if err != nil {
moduleJson = []byte(`{"full_text":" error"}`)
}
if listJson == "" {
listJson = string(moduleJson)
continue
}
listJson = listJson + "," + string(moduleJson)
}
fmt.Printf("[%s],\n", listJson)
}
func main() {
config = LoadConfig()
fmt.Println(`{"version": 1, "click_events": true}`)
fmt.Println(`[`)
fmt.Printf(
`[{"full_text": "loading status line...", "color": "%s"}],`,
config.Colors["WHITE"])
fmt.Println("")
go ReadInput()
go ListenToReloadConfig()
for _, m := range config.Modules {
if m.Signal >= 1 && m.Signal <= 15 {
go ListenFor(m.Signal, m.Name)
}
}
counter := 0
for {
for i := 0; i < len(config.Modules); i++ {
UpdateModule(i, counter, []string{})
}
draw()
time.Sleep(1 * time.Second)
counter += 1
}
}