dsts

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

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

Go to latest
Published: Aug 4, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

README

dsts

My custom status for i3bar.

There's no runtime configuration files. The whole point of this, is to have a single executable that just works.

License

MPL 2.0.

Documentation

Overview

Package dsts provides some basic types and functions for implementing the i3bar protocol.

Index

Constants

View Source
const (
	DefaultStatusColor      = "#999999"
	DefaultStatusColorError = "#e20024"
)

Variables

View Source
var (
	ErrNilStatusLineBlock = errors.New("nil status line block")
	ErrNilNotifier        = errors.New("nil notifier")
)
View Source
var ErrInvalidColor = errors.New("invalid color")

Functions

func IsValidColor

func IsValidColor(color string) bool

Types

type I3StatusLine

type I3StatusLine interface {
	AddNotifier(notifier Notifier) error

	AppendStatusLineBlocks(block ...*atomic.Pointer[StatusLineBlock]) error
	AppendStatusLineBlockProvider(p StatusLineBlockProvider) error

	Run() error
}

func NewI3StatusLine

func NewI3StatusLine(ctx context.Context, w io.Writer) (I3StatusLine, error)

type Notifier

type Notifier interface {
	// OnUpdate registers `callback` to be called when there's an update.
	//
	// It returns a function that, when called, should un-register `callback`
	// so that it's no longer called on updates.
	OnUpdate(callback NotifierCallbackFunc) RemoveCallbackFunc
}

Notifier can run callbacks when there's a new update on some data, so that the i3 status line can be redrawn.

type NotifierCallbackFunc

type NotifierCallbackFunc func()

type RemoveCallbackFunc

type RemoveCallbackFunc func()

type StatusLineBlock

type StatusLineBlock struct {
	FullText string `json:"full_text"`
	Color    string `json:"color,omitempty"`
}

StatusLineBlock is one block of an i3 status line.

type StatusLineBlockProvider

type StatusLineBlockProvider func(ctx context.Context, ch chan<- StatusLineBlock) error

StatusLineBlockProvider is a simplified way of producing status line blocks.

The function can run a loop and pass any updates to `ch`. It's meant to be called in its own goroutine, so it can block as long as needed, returning only when there's an error or when `ctx` is done.

func Wrap

Wrap limits the width of a provider's statuses.

When the underlying provider returns a status that surpasses the given width in characters, the wrapper will output at most `width` characters, and will automatically "scroll" back and forth, so the full status can be eventually read.

type UpdateNotifier

type UpdateNotifier func(callback NotifierCallbackFunc) RemoveCallbackFunc

UpdateNotifier is a wrapper for a function with the same signature as `Notifier.OnUpdate`, that implements `Notifier` by using itself as the `OnUpdate` method.

func (UpdateNotifier) OnUpdate

Directories

Path Synopsis
cmd
dsts command
dsts prints status updates to standard output, as expected by i3bar.
dsts prints status updates to standard output, as expected by i3bar.
Package tamrieltime implements functions for displaying current time and date, formatted as in Skyrim.
Package tamrieltime implements functions for displaying current time and date, formatted as in Skyrim.

Jump to

Keyboard shortcuts

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