patterns

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: MIT Imports: 27 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.

View Source
const MonitorLabel = "monitor"

Variables

View Source
var Events = &events.Manager{}

Events are where Watchers can be created and ChangeEvents are emitted.

Functions

func DesktopPatternEnv added in v0.5.0

func DesktopPatternEnv() (string, error)

DesktopPatternEnv returns an encoded environment variable needed to be passed along when run as root to preserve access to to the parent user's desktop configuration (gsettings).

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
	// contains filtered or unexported fields
}

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 ChangeEvent added in v0.4.9

type ChangeEvent struct {
	Pattern string
}

ChangeEvent is an event that is emitted when the running pattern is changed.

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.

func (*DesktopPattern) SetEnv added in v0.5.3

func (p *DesktopPattern) SetEnv(env string) error

SetEnv is invoked when the DesktopPattern needs additional environment values to pass along to the gsettings process (e.g. to ensure it monitors the right user desktop).

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
	// contains filtered or unexported fields
}

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.

type WatchPattern added in v0.4.9

type WatchPattern struct {
	BasePattern

	Out io.Writer
}

WatchPattern will report every color, brightness, and pattern change to the Out writer.

func (*WatchPattern) Run added in v0.4.9

func (p *WatchPattern) 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