-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (53 loc) · 1.33 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 (
"flag"
"runtime"
"github.com/mstarongithub/way2gay/config"
"github.com/sirupsen/logrus"
)
type StartMode int
// Start modes
const (
// Start as compositor
START_MODE_COMPOSITOR = StartMode(iota)
// Utilise tools, no compositing
START_MODE_TOOL
)
// command line flags
var (
// Path to the config file. Default is "config.toml"
configFile *string = flag.String("config", "config.toml", "path to the config file")
asTool *bool = flag.Bool("tool", false, "start as a tool instead of a compositor")
help *bool = flag.Bool("help", false, "show the help message for the various modes")
)
func init() {
// lock the main goroutine onto the current OS thread
// we need to do this because EGL uses thread local storage
// ----
// So far not found what happens if this isn't done - Melody
runtime.LockOSThread()
}
func main() {
flag.Parse()
// set up logging
if *help || *asTool {
logrus.SetLevel(logrus.ErrorLevel)
} else {
logrus.SetLevel(logrus.DebugLevel)
}
logrus.WithFields(logrus.Fields{
"configFile": *configFile,
"asTool": *asTool,
}).Debugln("Flags")
// Get config
conf, err := config.ParseConfig(*configFile)
if err != nil {
logrus.WithError(err).Warnln("Using config fall-back")
}
// And now run depending on mode
if *asTool {
utilMain(conf)
} else {
wlMain(conf)
}
}