funcs

package
v0.0.0-...-c936f35 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package funcs provides the ability to construct i3bar modules from simple Funcs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func func(bar.Sink)

Func receives a bar.Sink and uses it for output.

type OnceModule

type OnceModule struct {
	Func
}

OnceModule represents a bar.Module that runs a function once. If the function sets an error output, it will be restarted on the next click.

func Once

func Once(f Func) *OnceModule

Once constructs a bar module that runs the given function once. Useful if the function loops internally.

func (*OnceModule) Stream

func (o *OnceModule) Stream(s bar.Sink)

Stream starts the module.

type OnclickModule

type OnclickModule struct {
	Func
}

OnclickModule represents a bar.Module that runs a function and marks the module as finished, causing the next click to start the module again.

func OnClick

func OnClick(f Func) *OnclickModule

OnClick constructs a bar module that runs the given function when clicked. The function is given a Channel to allow multiple outputs (e.g. Loading... Done), and when the function returns, the next click will call it again.

func (OnclickModule) Stream

func (o OnclickModule) Stream(s bar.Sink)

Stream starts the module.

type RepeatingModule

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

RepeatingModule represents a bar.Module that runs a function at a fixed interval (while accounting for bar paused/resumed state).

func Every

func Every(d time.Duration, f Func) *RepeatingModule

Every constructs a bar module that repeatedly runs the given function. Useful if the function needs to poll a resource for output.

func (*RepeatingModule) Refresh

func (r *RepeatingModule) Refresh()

Refresh forces a refresh of the data being displayed.

func (*RepeatingModule) Stream

func (r *RepeatingModule) Stream(s bar.Sink)

Stream starts the module.

Jump to

Keyboard shortcuts

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