summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/main.go b/main.go
index 2eb1272..dd44b72 100644
--- a/main.go
+++ b/main.go
@@ -40,7 +40,7 @@ func reloadState(current *bspc.State) (*bspc.State, error) {
}
}
-func handleEvents(events *bspc.Subscriber, bar *bar.Handle) (chan error, chan bool) {
+func handleEvents(events *bspc.Subscriber) (chan error, chan bool) {
var event *bspc.Event
errors := make(chan error)
@@ -60,9 +60,10 @@ func handleEvents(events *bspc.Subscriber, bar *bar.Handle) (chan error, chan bo
switch (event.Name) {
case "monitor_add":
case "monitor_geometry":
- bar.Create <- id
+ common.Error("create2")
+ bar.Handle.Create <- id
case "monitor_remove":
- bar.Destroy <- id
+ bar.Handle.Destroy <- id
}
}
}
@@ -97,18 +98,18 @@ func main() {
}
defer events.Close()
- barhandle, err := bar.Init(state)
- if err != nil {
+ everr, evreload := handleEvents(events)
+
+ if bar.InitErr != nil {
common.Error("Couldn't initialize X: %s\n", err)
return
}
+ defer bar.Cleanup()
+ bar.Handle.NewState <- state
for _, m := range state.Monitors {
- barhandle.Create <- m.ID
+ bar.Handle.Create <- m.ID
}
- defer bar.Cleanup()
-
- everr, evreload := handleEvents(events, barhandle)
for {
select {
@@ -118,7 +119,7 @@ func main() {
case s := <- signals:
common.Error("%s\n", s)
return
- case err := <- barhandle.Err:
+ case err := <- bar.Handle.Err:
common.Error("%s\n", err)
return
case <- evreload:
@@ -130,12 +131,12 @@ func main() {
// Check if there's been an error before sending the
// new state (or else the program gets stuck)
select {
- case err := <- barhandle.Err:
+ case err := <- bar.Handle.Err:
common.Error("%s\n", err)
return
default:
}
- barhandle.NewState <- state
+ bar.Handle.NewState <- state
}
}
}