patterns

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package patterns include types that describe how colors and/or brightness should change. All should implement the Pattern interface and the BasePattern type will handle common logic across all patterns.

Index

Constants

View Source
const AllKeysLabel = "all-keys"

AllKeysLabel is used to get the all keys value from configuration.

View Source
const DefaultIdlePeriod = 30 * time.Second

DefaultIdlePeriod is the amount of time the TypingPattern will wait before declaring idle and, if configured, starting another pattern until keys are pressed again.

View Source
const DelayLabel = "delay"

DelayLabel is used to get the pattern delay from configuration.

View Source
const IdleLabel = "idle"

IdleLabel is used to get the idle pattern from configuration.

View Source
const IdlePeriodLabel = "idle-period"

IdlePeriodLabel is used to get the idle period from configuration.

View Source
const InputEventIDLabel = "input-event-id"

InputEventIDLabel is used to get the event ID from configuration.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasePattern

type BasePattern struct {
	Name string
	// contains filtered or unexported fields
}

BasePattern is part of all patterns that provides common attributes and implementation.

func (*BasePattern) GetBase

func (p *BasePattern) GetBase() *BasePattern

GetBase will return the BasePattern of any pattern.

func (*BasePattern) GetDefaultDelay

func (p *BasePattern) GetDefaultDelay() time.Duration

GetDefaultDelay will return the pattern's default delay.

func (*BasePattern) Run

func (p *BasePattern) Run(parent context.Context, log *zerolog.Logger) error

Run will begin executing a pattern. If the context passed in is canceled, the running pattern will stop.

func (*BasePattern) Stop

func (p *BasePattern) Stop()

Stop will terminate the currently running pattern.

func (*BasePattern) String

func (p *BasePattern) String() string

String will return a readable representation of the pattern.

type CPUPattern

type CPUPattern struct {
	BasePattern
}

CPUPattern is used when changing colors from "cold" (blue) to "hot" (red) according to the CPU utilization. The "delay" configuration value expresses the amount of time to wait between samples.

type Config added in v0.4.6

type Config interface {
	GetBool(string) bool
	GetDuration(string) time.Duration
	GetString(string) string
}

Config is the expected interface for retrieving configuration values.

func SetConfig added in v0.4.6

func SetConfig(cfg Config) Config

SetConfig is used to establish how to retrieve configuration values.

type DesktopPattern

type DesktopPattern struct {
	BasePattern
	// contains filtered or unexported fields
}

DesktopPattern is used when setting colors according to the dominant color of the active Gnome Desktop background picture.

type Pattern

type Pattern interface {
	GetDefaultDelay() time.Duration
	GetBase() *BasePattern
	Run(context.Context, *zerolog.Logger) error
	Stop()
	String() string
}

Pattern is the expected interface all patterns implement.

func Get

func Get(name string) Pattern

Get will return a registered Pattern by name.

func GetRunning

func GetRunning() Pattern

GetRunning will return nil or the currently running pattern.

type PulsePattern

type PulsePattern struct {
	BasePattern
}

PulsePattern is used when stepping the brightness values up and down to emulate a slow "pulsing" effect. The "delay" configuration value expresses the amount of time to wait between changes of the brightness.

type RainbowPattern

type RainbowPattern struct {
	BasePattern
}

RainbowPattern is used when changing colors through the traditional colors of a rainbow. The "delay" configuration value expresses the amount of time to wait between changes of color.

type RandomPattern

type RandomPattern struct {
	BasePattern
}

RandomPattern is used when changing colors by randomly selecting a color value. The "delay" configuration value expresses the amount of time to wait between changes of color.

type TypingPattern

type TypingPattern struct {
	BasePattern
}

TypingPattern is used when changing when changing colors from "cold" (blue) to "hot" (red) according to the speed of key presses occurring. The "delay" configuration value expresses the amount of time to wait between evaluating the number of keys recently pressed.

func (*TypingPattern) String

func (p *TypingPattern) String() string

String is a customized version of the BasePattern String that also includes information about the idle settings.

type WaitPattern

type WaitPattern struct {
	BasePattern
}

WaitPattern is a special kind of pattern that doesn't do anything, instead, waiting on external commands to be issued (by the menu or another cli) to trigger a pattern.

func (*WaitPattern) Run

func (p *WaitPattern) Run(parent context.Context, _ *zerolog.Logger) error

Run is overriding the BasePattern version as a special case and will hang forever, waiting for the parent context to interrupt.

Jump to

Keyboard shortcuts

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