core

package
v0.0.0-...-8a10bf9 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ButtonLeft       eventButton = 1
	ButtonMiddle     eventButton = 2
	ButtonRight      eventButton = 3
	ButtonScrollUp   eventButton = 4
	ButtonScrollDown eventButton = 5
)
View Source
const (
	BlockAlignLeft   blockAlign = "left"
	BlockAlignRight  blockAlign = "right"
	BlockAlignCenter blockAlign = "center"
)

Variables

Functions

func CountryFlagFromIsoCode

func CountryFlagFromIsoCode(countryCode string) string

func InitBlockletLogger

func InitBlockletLogger(log **logLib.Logger)

func InitializeLogger

func InitializeLogger(out io.Writer)

func LogFromBlocklet

func LogFromBlocklet(b I3barBlocklet)

func PercentageToHue

func PercentageToHue(p int) int

func RegisterBlocklet

func RegisterBlocklet(name string, ctor I3barBlockletCtor)

Types

type AppConfig

type AppConfig struct {
	Version        string           `yaml:"version"`
	SeparatorWidth int              `yaml:"separator_width"`
	Markup         I3barMarkup      `yaml:"markup"`
	Blocks         []BlockletConfig `yaml:"blocks"`
	Theme          *ThemeConfig     `yaml:"theme"`
	WatchConfig    *bool            `yaml:"watch_config"`
}

func LoadConfigFromFile

func LoadConfigFromFile(filename string) (*AppConfig, error)

func (*AppConfig) CreateManagers

func (cfg *AppConfig) CreateManagers(ctx context.Context) []BlockletMgr

type BaseBlockletConfig

type BaseBlockletConfig struct {
	Color   *ConfigColor `yaml:"color,omitempty"`
	OnClick *string      `yaml:"on_click"`
}

func (*BaseBlockletConfig) Get

type BaseBlockletConfigIface

type BaseBlockletConfigIface interface {
	Get() *BaseBlockletConfig
}

type BlockletConfig

type BlockletConfig struct {
	Name string `yaml:"name"`
	// Path to plugin, if `name == "plugin"`
	Path string                 `yaml:"path"`
	Rest map[string]interface{} `yaml:",inline"`
}

type BlockletMgr

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

A helper wrapper around a blocklet TODO: utilize `instance` field, as defined in the i3bar protocol

func MakeBlockletMgr

func MakeBlockletMgr(
	name string,
	b I3barBlocklet,
	cfg *AppConfig,
) BlockletMgr

func (*BlockletMgr) IsListener

func (bm *BlockletMgr) IsListener() bool

func (*BlockletMgr) MatchesEvent

func (bm *BlockletMgr) MatchesEvent(e *I3barClickEvent) bool

func (*BlockletMgr) ProcessEvent

func (bm *BlockletMgr) ProcessEvent(
	e *I3barClickEvent,
	ctx context.Context,
	wg *sync.WaitGroup,
) bool

func (*BlockletMgr) Render

func (bm *BlockletMgr) Render() []I3barBlock

func (*BlockletMgr) Run

func (bm *BlockletMgr) Run(ch chan string, ctx context.Context, wg *sync.WaitGroup)

func (*BlockletMgr) TryInvalidate

func (bm *BlockletMgr) TryInvalidate(name string)

If name matches blocklet manager name, re-render blocklets

type ConfigColor

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

func FromHSV

func FromHSV(h, s, v int) *ConfigColor

func FromRGB

func FromRGB(r, g, b uint8) *ConfigColor

func FromRGBA

func FromRGBA(r, g, b, a uint8) *ConfigColor

func (*ConfigColor) String

func (c *ConfigColor) String() string

func (*ConfigColor) UnmarshalYAML

func (c *ConfigColor) UnmarshalYAML(node *yaml.Node) (err error)

type ConfigFormat

type ConfigFormat struct {
	formatting.RustLikeFmt
}

TODO: use different formatters?

func NewConfigFormatFromString

func NewConfigFormatFromString(s string) *ConfigFormat

type ConfigInterval

type ConfigInterval time.Duration

func NewFromString

func NewFromString(v string) (*ConfigInterval, error)

func (*ConfigInterval) UnmarshalYAML

func (c *ConfigInterval) UnmarshalYAML(value *yaml.Node) (err error)

type I3barBlock

type I3barBlock struct {
	// The text that will be displayed. If missing, the block will be skipped.
	FullText string `json:"full_text"`

	// If given and the text needs to be shortened due to space, this will be
	// displayed instead of full_text
	ShortText string `json:"short_text,omitempty"`

	// The text color to use in #RRGGBBAA or #RRGGBB notation
	Color string `json:"color,omitempty"`

	// The background color for the block in #RRGGBBAA or #RRGGBB notation
	Background string `json:"background,omitempty"`

	// The border color for the block in #RRGGBBAA or #RRGGBB notation
	Border string `json:"border,omitempty"`

	// The height in pixels of the top border. The default is 1
	BorderTop int `json:"border_top,omitempty"`

	// The height in pixels of the bottom border. The default is 1
	BorderBottom int `json:"border_bottom,omitempty"`

	// The width in pixels of the left border. The default is 1
	BorderLeft int `json:"border_left,omitempty"`

	// The width in pixels of the right border. The default is 1
	BorderRight int `json:"border_right,omitempty"`

	// TODO: custom type
	MinWidth int `json:"min_width"`

	// If the text does not span the full width of the block, this specifies
	// how the text should be aligned inside of the block. This can be left
	// (default), right, or center.
	Align blockAlign `json:"align,omitempty"`

	// A name for the block. This is only used to identify the block for click
	// events. If set, each block should have a unique name and instance pair.
	Name string `json:"name,omitempty"`

	// The instance of the name for the block. This is only used to identify the
	// block for click events. If set, each block should have a unique name and
	// instance pair.
	Instance string `json:"instance,omitempty"`

	// Whether the block should be displayed as urgent. Currently swaybar
	// utilizes the colors set in the sway config for urgent workspace buttons.
	// See sway-bar(5) for more information on bar color configuration.
	Urgent bool `json:"urgent,omitempty"`

	// Whether the bar separator should be drawn after the block. See
	// sway-bar(5) for more information on how to set the separator text.
	Separator bool `json:"separator,omitempty"`

	// The amount of pixels to leave blank after the block. The separator text
	// will be displayed centered in this gap. The default is 9 pixels.
	SeparatorBlockWidth int `json:"separator_block_width,omitempty"`

	// The type of markup to use when parsing the text for the block. This can
	// either be pango or none (default).
	Markup I3barMarkup `json:"markup,omitempty"`
}

type I3barBlocklet

type I3barBlocklet interface {
	Run(ch UpdateChan, ctx context.Context)
	Render(cfg *AppConfig) []I3barBlock
}

type I3barBlockletConfigurable

type I3barBlockletConfigurable interface {
	I3barBlocklet
	GetConfig() interface{}
}

type I3barBlockletCtor

type I3barBlockletCtor func() I3barBlocklet

func GetBuiltin

func GetBuiltin(name string) I3barBlockletCtor

type I3barBlockletListener

type I3barBlockletListener interface {
	I3barBlocklet
	OnEvent(*I3barClickEvent, context.Context)
}

type I3barBlockletLogger

type I3barBlockletLogger interface {
	I3barBlocklet
	GetLogger() *log.Logger
}

type I3barClickEvent

type I3barClickEvent struct {
	Name      string      `json:"name"`
	Instance  string      `json:"instance"`
	X         int         `json:"x"`
	Y         int         `json:"y"`
	Button    eventButton `json:"button"`
	Event     int         `json:"event"`
	RelativeX int         `json:"relative_x"`
	RelativeY int         `json:"relative_y"`
	Width     int         `json:"width"`
	Height    int         `json:"height"`
}

func NewEventFromRaw

func NewEventFromRaw(raw []byte) (*I3barClickEvent, error)

func (*I3barClickEvent) CustomBlockletName

func (e *I3barClickEvent) CustomBlockletName() string

func (*I3barClickEvent) ShellCommand

func (e *I3barClickEvent) ShellCommand(
	command string,
	ctx context.Context,
) *exec.Cmd

type I3barHeader

type I3barHeader struct {
	Version     int  `json:"version"`
	ClickEvents bool `json:"click_events,omitempty"`
	ContSignal  int  `json:"cont_signal,omitempty"`
	StopSignal  int  `json:"stop_signal,omitempty"`
}

type I3barMarkup

type I3barMarkup string
const (
	MarkupNone  I3barMarkup = "none"
	MarkupPango I3barMarkup = "pango"
)

type Logger

type Logger struct{}

func NewLogger

func NewLogger() *Logger

type Render

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

func MakeRender

func MakeRender() Render

func (*Render) Block

func (r *Render) Block(b I3barBlock)

func (*Render) Build

func (r *Render) Build() []I3barBlock

func (*Render) Markup

func (r *Render) Markup(m I3barMarkup)

type ThemeConfig

type ThemeConfig struct {
	Saturation int `yaml:"saturation"`
	Value      int `yaml:"value"`
}

func (*ThemeConfig) HSVColor

func (t *ThemeConfig) HSVColor(hue int) *ConfigColor

type UpdateChan

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

func (*UpdateChan) SendUpdate

func (u *UpdateChan) SendUpdate()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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