Exemple #1
0
func Open() (*Fifo, error) {
	var pipe Fifo
	pipe.path = defaultPath
	if config.Has("global.fifo") {
		pipe.path, _ = config.String("config.fifo")
	}

	if _, err := os.Stat(pipe.path); err == nil {
		err = os.Remove(pipe.path)
		if err != nil {
			return nil, err
		}
	}

	if err := syscall.Mkfifo(pipe.path, 0777); err != nil {
		return nil, err
	}

	fd, err := syscall.Open(pipe.path, syscall.O_RDONLY|syscall.O_NONBLOCK, 0777)
	if err != nil {
		return nil, err
	}

	pipe.fd = fdReader(fd)
	pipe.rd = bufio.NewReader(pipe.fd)
	pipe.cmds = make([]Command, 0, 5)
	return &pipe, nil
}
Exemple #2
0
func loadGCS(c *xgb.Conn, scr *xproto.ScreenInfo) error {
	if !config.Has("global.list") {
		return InvalidConfig("no global.list")
	}
	err := loadDefaultGC(c, scr)
	if err != nil {
		return err
	}

	list, _ := config.String("global.list")
	entries := strings.Split(list, ",")
	for _, entry := range entries {
		err = loadGC(entry, c, scr)
		if err != nil {
			/* TODO Clean previously loaded gcs */
			return err
		}
	}
	return nil
}
Exemple #3
0
func loadDefaultGC(c *xgb.Conn, scr *xproto.ScreenInfo) error {
	var font string
	if config.Has("global.gc.font") {
		font, _ = config.String("global.gc.font")
	} else {
		font = defaultFont
	}
	fnt, err := openFont(c, font)
	if err != nil {
		return err
	}
	defaultgc.font = uint32(fnt)

	if config.Has("global.width") {
		wd, _ := config.Int("global.width")
		defaultgc.width = uint32(wd)
	} else {
		defaultgc.width = 500
	}

	if config.Has("global.gc.width") {
		wd, _ := config.Int("global.gc.width")
		defaultgc.border = uint32(wd)
	} else {
		defaultgc.border = 5
	}

	var cl color
	if config.Has("global.gc.fg") {
		str, _ := config.String("global.gc.fg")
		cl = readColor(str)
	} else {
		cl = color{255, 255, 255}
	}
	defaultgc.fg, err = openColor(c, scr, cl)
	if err != nil {
		return err
	}

	if config.Has("global.gc.bg") {
		str, _ := config.String("global.gc.bg")
		cl = readColor(str)
	} else {
		cl = color{0, 0, 0}
	}
	defaultgc.bg, err = openColor(c, scr, cl)
	if err != nil {
		return err
	}

	if config.Has("global.gc.bc") {
		str, _ := config.String("global.gc.bc")
		cl = readColor(str)
	} else {
		cl = color{255, 255, 255}
	}
	defaultgc.bc, err = openColor(c, scr, cl)
	if err != nil {
		return err
	}
	return nil
}