helpers

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWeatherFormat = "1"

DefaultWeatherFormat is the default wttr.in weather format. See https://github.com/chubin/wttr.in#one-line-output for more details

Variables

View Source
var ErrHelperNotFound = fmt.Errorf("helper not found")

ErrHelperNotFound means no helper exists by the specified name

Functions

func Register

func Register(name string, helper Helper)

Register registers a new helper by name

func Run

func Run(name, config string) (string, error)

Run executes a helper with the provided config string

Types

type BashHelper

type BashHelper struct {
}

BashHelper runs a bash command and displays the output

func (*BashHelper) Run

func (h *BashHelper) Run(config string) string

Run runs a bash command and displays the output

func (*BashHelper) UpdateInterval

func (h *BashHelper) UpdateInterval() time.Duration

UpdateInterval returns the minimum time period before the helper should run again

type BatteryHelper

type BatteryHelper struct {
}

BatteryHelper shows the current battery charge level as a percentage

func (*BatteryHelper) Run

func (h *BatteryHelper) Run(config string) string

Run returns the current battery charge level as a percentage

func (*BatteryHelper) UpdateInterval

func (h *BatteryHelper) UpdateInterval() time.Duration

UpdateInterval returns the minimum time period before the helper should run again

type CPUHelper

type CPUHelper struct {
}

CPUHelper shows the current cpu usage as a percentage

func (*CPUHelper) Run

func (h *CPUHelper) Run(config string) string

Run returns the current cpu usage as a percentage

func (*CPUHelper) UpdateInterval

func (h *CPUHelper) UpdateInterval() time.Duration

UpdateInterval returns the minimum time period before the helper should run again

type Helper

type Helper interface {
	Run(config string) string      // Run starts the helper and returns the output
	UpdateInterval() time.Duration // UpdateInterval returns the minimum time period before the helper should run again
}

Helper is a dynamic operation which creates output for the status bar

type HelperRun added in v0.0.18

type HelperRun struct {
	// contains filtered or unexported fields
}

HelperRun represents a single run of a helper

func (HelperRun) Output added in v0.0.18

func (hr HelperRun) Output() string

Output returns the output of the run

func (HelperRun) Time added in v0.0.18

func (hr HelperRun) Time() time.Time

Time returns the time of the run

type HelperRunCache added in v0.0.18

type HelperRunCache struct {
	// contains filtered or unexported fields
}

HelperRunCache stores the last run of all unique helpers. A helper is defined by its name and config

func NewHelperRunCache added in v0.0.18

func NewHelperRunCache() HelperRunCache

NewHelperRunCache creates a new helper run cache

func (*HelperRunCache) GetOrAdd added in v0.0.18

func (c *HelperRunCache) GetOrAdd(key string) HelperRun

GetOrAdd tries to find an item in the cache and creates one if not found

func (*HelperRunCache) Key added in v0.0.18

func (c *HelperRunCache) Key(parts ...string) string

Key generates a cache key from a Helper's attributes

func (*HelperRunCache) Put added in v0.0.18

func (c *HelperRunCache) Put(key, output string)

Put updates an existing item in the cache or creates one if not found

type MemoryHelper

type MemoryHelper struct {
}

MemoryHelper shows the current memory usage as a percentage

func (*MemoryHelper) Run

func (h *MemoryHelper) Run(config string) string

Run returns the current memory usage as a percentage

func (*MemoryHelper) UpdateInterval

func (h *MemoryHelper) UpdateInterval() time.Duration

UpdateInterval returns the minimum time period before the helper should run again

type TimeHelper

type TimeHelper struct {
}

TimeHelper shows the current time

func (*TimeHelper) Run

func (h *TimeHelper) Run(config string) string

Run returns the current time

func (*TimeHelper) UpdateInterval

func (h *TimeHelper) UpdateInterval() time.Duration

UpdateInterval returns the minimum time period before the helper should run again

type UntilHelper added in v0.0.18

type UntilHelper struct {
}

TimeHelper shows the current time

func (*UntilHelper) Run added in v0.0.18

func (h *UntilHelper) Run(config string) string

Run returns the current time

func (*UntilHelper) UpdateInterval added in v0.0.18

func (h *UntilHelper) UpdateInterval() time.Duration

UpdateInterval returns the minimum time period before the helper should run again

type WeatherHelper

type WeatherHelper struct {
}

WeatherHelper shows the current weather

func (*WeatherHelper) Run

func (h *WeatherHelper) Run(config string) string

Run returns the current weather

func (*WeatherHelper) UpdateInterval

func (h *WeatherHelper) UpdateInterval() time.Duration

UpdateInterval returns the minimum time period before the helper should run again

Jump to

Keyboard shortcuts

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