Example #1
0
func main() {
	/* Loading config */
	if err := config.Load(config.ConfigPath()); err != nil {
		fmt.Printf("Error when loading config : %v\n", err)
		return
	}

	/* Opening the connection */
	var conn *xgb.Conn
	if c, err := xgb.NewConn(); err != nil {
		fmt.Printf("Error when connecting to x11 server : %v\n", err)
		return
	} else {
		conn = c
	}
	defer conn.Close()

	/* Loading screens configuration */
	if err := screens.Load(conn); err != nil {
		fmt.Printf("Error while getting screens configuration : %v\n", err)
		return
	}

	/* Loading window manager */
	if err := window.Load(conn); err != nil {
		fmt.Printf("Error while loading window manager : %v\n", err)
		return
	}

	/* Opening the fifo */
	var pipe *fifo.Fifo
	if p, err := fifo.Open(); err != nil {
		fmt.Printf("Error while opening the fifo : %s\n", err)
		return
	} else {
		pipe = p
	}
	defer pipe.Close()
	cmds := [...]fifo.Command{
		&KillCommand{},
		&RedrawCommand{},
		&CloseCommand{false, false, 0},
		&NotifCommand{0, "", ""},
	}
	for _, cmd := range cmds {
		pipe.AddCmd(cmd)
	}

	/* Opening the queue */
	var notifs *queue.Queue
	if q, err := queue.Open(conn); err != nil {
		fmt.Printf("Error while opening the queue : %s\n", err)
		return
	} else {
		notifs = q
	}

	/* Main loop */
	orders := make(chan types.Order, 10)
	go xloop(conn, orders)
	go pipe.ReadOrders(orders)
	notifs.Run(orders)
}