lib

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlertEvent

func AlertEvent(config *Config, event *Event)

func AlertIfCritical

func AlertIfCritical(config *Config, battery *Battery)

func AlertNotify

func AlertNotify(config *Config, event *Event)

func AlertSet

func AlertSet(config *Config, battery *Battery, state bool)

func AlertSound

func AlertSound(config *Config, event *Event)

func DefaultConfig

func DefaultConfig() string

func GetBatteries

func GetBatteries() (*list.List, error)

func ListIn

func ListIn[T any](
	l *list.List,
	m *list.List,
	compare func(a T, b T) bool,
	callback func(*list.Element, bool),
)

func ListMap

func ListMap[T any](l *list.List, callback func(T))

func ListMirror

func ListMirror[T any](
	l *list.List,
	m *list.List,
	compare func(T, T) bool,
	callback func(ListEvent[T]),
)

ListMirror the elements of `m' in `l', i.e., remove elements from `l' that do not belong to `m' and add elements from `m' that do not belong to `l'.

func ListRepr

func ListRepr(l *list.List) string

func Play

func Play(filename string) error

func PlaySafe

func PlaySafe(filename string)

func SetLogDebug

func SetLogDebug(flag bool)

func SetLogFile

func SetLogFile(filename string) error

func Update

func Update(batteries *list.List, callback func(Event))

Types

type AlertConfig

type AlertConfig struct {
	Added       string `yaml:"added"`
	Removed     string `yaml:"removed"`
	Charging    string `yaml:"charging"`
	Discharging string `yaml:"discharging"`
	Full        string `yaml:"full"`
	Idle        string `yaml:"idle"`
	Empty       string `yaml:"empty"`
	Critical    string `yaml:"critical"`
}

type Battery

type Battery struct {
	Id   int
	Name string
	Last Snapshot
	Api  *impl.Battery
}

func (*Battery) Capacity

func (battery *Battery) Capacity() float64

func (*Battery) Charging

func (battery *Battery) Charging() bool

func (*Battery) Compare

func (battery *Battery) Compare(c float64) float64

func (*Battery) Discharging

func (battery *Battery) Discharging() bool

func (*Battery) Full

func (battery *Battery) Full() bool

func (*Battery) Glyph

func (battery *Battery) Glyph() string

func (*Battery) GoString

func (battery *Battery) GoString() string

func (*Battery) String

func (battery *Battery) String() string

func (*Battery) Update

func (battery *Battery) Update() (bool, error)

type BatteryConfig

type BatteryConfig struct {
	Name     string  `yaml:"name"`
	Critical float64 `yaml:"critical"`
	Alerted  bool
}

type Config

type Config struct {
	Batteries []*BatteryConfig `yaml:"batteries"`
	Alerts    AlertConfig      `yaml:"alerts"`
	LogFile   string           `yaml:"logfile"`
	Verbose   bool             `yaml:"verbose"`
}

func LoadConfig

func LoadConfig(filename string) (Config, error)

func (*Config) Get

func (config *Config) Get(battery *Battery) *BatteryConfig

func (*Config) Load

func (config *Config) Load(filename string) error

type Event

type Event struct {
	Kind    EventType
	Battery *Battery
}

func (Event) String

func (event Event) String() string

type EventType

type EventType int8
const (
	Charging EventType = iota
	Discharging
	Idle
	Empty
	Full
	Added
	Removed
)

func (EventType) String

func (eventType EventType) String() string

type ListEvent

type ListEvent[T any] struct {
	Kind    ListEventType
	Element T
}

type ListEventType

type ListEventType int8
const (
	ElementAdded ListEventType = iota
	ElementRemoved
)

type ListResult

type ListResult struct {
	Element *list.Element
	Found   bool
}

type Logger

type Logger struct {
	// contains filtered or unexported fields
}
var Log Logger = Logger{
	// contains filtered or unexported fields
}

func (Logger) Dbg

func (l Logger) Dbg(format string, args ...any)

func (Logger) Err

func (l Logger) Err(format string, args ...any)

func (Logger) ErrWrap

func (l Logger) ErrWrap(err error)

func (Logger) Info

func (l Logger) Info(format string, args ...any)

func (Logger) Warn

func (l Logger) Warn(format string, args ...any)

type Snapshot

type Snapshot struct {
	State impl.AgnosticState
	When  time.Time
}

type SoundError

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

func (SoundError) Error

func (err SoundError) Error() string

Jump to

Keyboard shortcuts

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