The Barista Logo

barista

An i3status alternative in golang

Download sample-bar Download i3status example View on GitHub

Groups

godoc
import "barista.run/group"

The group package provides a base for grouping modules and selectively displaying them on the bar. There are several default groups:

group.Simple

In addition to the more functional default groups, barista also includes group.Simple(...) that simply concatenates several modules into one:

newModule = group.Simple(mod1, mod2, mod3)

Allowing multiple modules to be added anywhere a single module is expected, for example, in the cycling or switching groups.

Implementing a Custom Group

If none of the built-in groupers are a perfect fit, you can also write your own grouper. The basic interface is

// Grouper controls how a group displays the output from it's modules.
type Grouper interface {
	Visible(index int) bool
	Buttons() (start, end bar.Output)
}

Additional interfaces, if implemented, provide even more control over the output:

type UpdateListener interface {
	Updated(index int)
}

If the grouper implements UpdateListener, the Update(int) method will be called with the index of the module that was most recently updated.

type Signaller interface {
	Signal() <-chan struct{}
}

If the grouper implements Signaller, the Signal() method will be called during the initial stream, and any updates the the returned channel will cause the group to recalculate the displayed output using the last output from each module.