wm/cmd/bspwm/main.go

43 lines
615 B
Go
Raw Normal View History

2022-12-26 05:06:40 +00:00
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
}
}
}