The Barista Logo

barista

An i3status alternative in golang

Download sample-bar Download i3status example View on GitHub

Battery

godoc
import "barista.run/modules/battery"

Display information about a specific battery: battery.Named("BAT0").
Display aggregated information for all available batteries: battery.All().

Aggregated information effectively creates a “virtual” battery where the stats are sensibly merged or computed across all available batteries. For example, the Energy Now is just a sum of all batteries, but the Voltage is a weighted average (by max energy), while Technology is a comma-separated merger of individual battery technologies.

Configuration

Examples

4h33m

Show time remaining on battery (or to full charge if plugged in):

battery.All().Output(func(i battery.Info) bar.Output) {
	return outputs.Text(i.RemainingTime().String())
})
46Wh+13W
97Wh-21W

Show the energy stored and usage rate for a specific battery:

battery.Named("BAT0").Output(func(i battery.Info) bar.Output {
	sep := "+"
	if i.Discharging() {
		sep = "-"
	}
	return outputs.Textf("%.0fWh%s%.0fW", i.EnergyNow, sep, i.Power)
})

Data: type Info struct

Fields

Methods