The Barista Logo

barista

An i3status alternative in golang

Download sample-bar Download i3status example View on GitHub

Memory Information

godoc
import "barista.run/modules/meminfo"

Display memory information: meminfo.New().

Configuration

Because the meminfo module performs a single read of /proc/meminfo to update all instances, the refresh interval can only be set for the package as a whole.

Examples

0.4/1.8G

Show the used and total swap space:

meminfo.New().Output(func(i meminfo.Info) bar.Output) {
	return outputs.Textf("%.1f/%.1fG",
		i["SwapFree"].Gigabytes(), i["SwapTotal"].Gigabytes())
})
mem:40%/swap:0%

Show the percentage of main memory and swap used:

meminfo.New().Output(func(i meminfo.Info) bar.Output) {
	return outputs.Textf("mem:%.0f%%/swap:%.0f%%",
		(1 - i.FreeFrac("Mem")) * 100.0,
		(1 - i.FreeFrac("Swap")) * 100.0,
	)
})

Data: type Info map[string]unit.Datasize

Keys

Any key in /proc/meminfo is also available in Info, parsed into a unit.Datasize. The most useful keys are:

Methods

Documentation for unit.Datarate