package main import ( "context" "fmt" "log" "os" "os/signal" "syscall" "tuxpa.in/t/wm/src/handler" "tuxpa.in/t/wm/src/sock" ) func main() { 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) defer stop() h := &handler.Handler{} for { select { case m := <-ln.Msg(): log.Printf("got cmd: %s", m.Args()) h.Run(m) case <-ctx.Done(): fmt.Println() log.Printf("bspwm shutting down...") return } } }