package main import ( "context" "log" "os" "os/signal" "syscall" "tuxpa.in/t/wm/src/bsp" "tuxpa.in/t/wm/src/handler" "tuxpa.in/t/wm/src/handler/domains" "tuxpa.in/t/wm/src/sock" ) func main() { // create socket ln, err := sock.Server("./bspwm.sock") if err != nil { panic(err) } defer ln.Close() log.Printf("starting bspwm") ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT, ) defer stop() // initialize WM state w := bsp.NewWM() // create a wm manager xwm := bsp.NewXWM(w, ln.X11()) // install the handler h := &handler.Handler{ XWM: xwm, } handler.AddDomain[domains.Todo](h, "node") handler.AddDomain[domains.Todo](h, "desktop") handler.AddDomain[domains.Todo](h, "monitor") handler.AddDomain[domains.Todo](h, "wm") handler.AddDomain[domains.Todo](h, "rule") handler.AddDomain[domains.Todo](h, "config") handler.AddDomain[domains.Todo](h, "subscribe") handler.AddDomain[domains.Todo](h, "quit") handler.AddDomain[domains.Query](h, "query") handler.AddDomain[domains.Echo](h, "echo") for { select { case m := <-ln.Msg(): h.Run(m) case <-ctx.Done(): log.Println("bspwm shutting down...") return } } }