-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
70 lines (58 loc) · 1.32 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
package main
import (
"os"
log "github.com/sirupsen/logrus"
"github.com/alecthomas/kingpin"
"github.com/mikkeloscar/flis/backend"
"github.com/mikkeloscar/flis/compositor"
"github.com/mikkeloscar/flis/config"
"github.com/mikkeloscar/flis/layout/i3"
wlc "github.com/mikkeloscar/go-wlc"
)
var (
version = "unknown"
flags struct {
Config string
Debug bool
Validate bool
}
)
func init() {
kingpin.
Flag("config", "Path to config file").Short('c').
StringVar(&flags.Config)
kingpin.
Flag("debug", "Enable debug logging").Short('d').
BoolVar(&flags.Debug)
kingpin.
Flag("validate", "Validate config file and exit").Short('C').
BoolVar(&flags.Validate)
kingpin.Version(version)
}
func main() {
kingpin.Parse()
// configure log level
if flags.Debug {
log.SetLevel(log.DebugLevel)
}
conf, err := config.LoadConfig(flags.Config)
if err != nil {
log.Errorf("Failed to parse config '%s': %s", flags.Config, err)
os.Exit(1)
}
if flags.Validate {
log.Info("Config is valid")
os.Exit(0)
}
// initialize compositor
comp := compositor.New(conf, &backend.WLC{}, i3.New())
wlc.SetOutputCreatedCb(comp.OutputCreated)
wlc.SetViewCreatedCb(comp.ViewCreated)
wlc.SetPointerMotionCb(comp.PointerMotion)
wlc.SetKeyboardKeyCb(comp.KeyboardKey)
if !wlc.Init() {
os.Exit(1)
}
wlc.Run()
os.Exit(0)
}