Documentation
¶
Overview ¶
Package dsts provides some basic types and functions for implementing the i3bar protocol.
Index ¶
Constants ¶
const ( DefaultStatusColor = "#999999" DefaultStatusColorError = "#e20024" )
Variables ¶
var ( ErrNilStatusLineBlock = errors.New("nil status line block") ErrNilNotifier = errors.New("nil notifier") )
var ErrInvalidColor = errors.New("invalid color")
Functions ¶
func IsValidColor ¶
Types ¶
type I3StatusLine ¶
type I3StatusLine interface {
AddNotifier(notifier Notifier) error
AppendStatusLineBlocks(block ...*atomic.Pointer[StatusLineBlock]) error
AppendStatusLineBlockProvider(p StatusLineBlockProvider) error
Run() error
}
func NewI3StatusLine ¶
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 ¶
func Wrap(p StatusLineBlockProvider, width int) StatusLineBlockProvider
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 ¶
func (fn UpdateNotifier) OnUpdate(callback NotifierCallbackFunc) RemoveCallbackFunc
Source Files
¶
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. |