The Barista Logo

barista

An i3status alternative in golang

Download sample-bar Download i3status example View on GitHub

Reformat

godoc
import "barista.run/modules/meta/reformat"

Reformat provides a module that modifies the output from an existing module before sending it to the bar. It also provides utility functions to make transformations easier.

Reformatting an existing module: reformat.New(existingModule).Format(formatFunc).

Default Formatters

There are some formatting functions available out of the box:

In addition, reformat also provides SkipErrors(SegmentFunc) that wraps an existing SegmentFunc with code to return error segments unchanged, potentially simplifying the transformation code.

Example

Error**Liftoff!**

Adding ‘**’ around all non-error output:

// countdown is a module that outputs an error and a countdown.
reformat.New(countdown).Format(
	reformat.EachSegment(
		reformat.SkipErrors(func(in *bar.Segment) *bar.Segment {
			txt, _ := in.Content()
			return in.Text("**" + txt + "**")
		})))