i3gobar

package module
v0.0.0-...-a823470 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2017 License: BSD-2-Clause Imports: 12 Imported by: 0

README

i3gobar

A super simple package for making your own custom i3bar status line.

Why does this exist?

Becasue when configuration files get too complicated sometimes it's easier to just write your own program configured the way you want. That is the conclusion I reached after trying to configure various bars just the way I like them.

This little library makes it super easy to make your own stats bar that does exactly what you want it to.

How do I use this thing?

See main.go for a complete example. It's that easy. Define your array of what functions you want adding blocks to your status in the order you want them, and define your own functions which simply return a block down the provided channel. Each function runs asynchronously and handles it's own timing so each block can refresh it's data as frequently as you want.

Some functions that I thought other people might like, like Load, CPU and Memory I built into the library, so if you like the way they look, just use them. If you don't, it's easy to build your own.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Batt

func Batt(uc chan<- []I3Block)

func CPU

func CPU(uc chan<- []I3Block)

CPU returns cpu time usage every second for each core. Color shifts from green to red as the usage approaches 100

func CPUGraph

func CPUGraph(uc chan<- []I3Block)

func ColorString

func ColorString(s string, n float64) string

ColorString returns a pango formatted string colored between green and red with the provided value

func Date

func Date(uc chan<- []I3Block)

func DateTime

func DateTime(uc chan<- []I3Block)

func GetColor

func GetColor(n float64) string

GetColor returns a color between green and red where 0 = green and 100 = red

func LoadAvg

func LoadAvg(uc chan<- []I3Block)

LoadAvg prints the load average for 1, 5 and 15 minutes every second. Color for each load shifts from green to red as it approaches the number of cores on the system.

func MemFree

func MemFree(uc chan<- []I3Block)

MemFree prints the free memory in human readable units. Is green as long as there is 1GiB free, shifts red as the free memory approaches zero.

func Run

func Run(f []func(chan<- []I3Block), noSeparator bool, separatorBlockWidth int)

Run runs all the specified functions, and prints the output to be consumed by i3bar. It runs each function in a goroutine and updates the bar when any of them return data on the return channel.

func SwapUsed

func SwapUsed(uc chan<- []I3Block)

SwapUsed shows the swap space in use. Turns red once more than 100 bytes are used.

func TimeLocal

func TimeLocal(uc chan<- []I3Block)

func TimeUTC

func TimeUTC(uc chan<- []I3Block)

func Uptime

func Uptime(uc chan<- []I3Block)

Types

type I3Block

type I3Block struct {
	FullText            string `json:"full_text"`
	ShortText           string `json:"short_text,omitempty"`
	Color               string `json:"color,omitempty"`
	Background          string `json:"background,omitempty"` // background color
	Border              string `json:"border,omitempty"`     // border color
	MinWidth            int    `json:"min_width,omitempty"`
	Align               string `json:"align,omitempty"` // center, right or left alignment of text in block
	Name                string `json:"name,omitempty"`  // not used by i3, used for click_events
	Instance            string `json:"instance,omitempty"`
	Urgent              bool   `json:"urgent"`
	NoSeparator         bool   `json:"-"`                               // Specify as true to omit the spearator after this field
	SeparatorBlockWidth int    `json:"separator_block_width,omitempty"` // pixels to be left blank after the block
	Markup              string `json:"markup,omitempty"`                // set to pango for pango markup
}

I3Block represents a block to be printed on the bar. See the i3bar protocol documentation for details on each property

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL