config

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config carries every path and tunable of lys-power, with environment overrides so tests and exotic setups can redirect the sysfs, state and runtime locations without recompiling.

Index

Constants

View Source
const (
	DefaultSupplyDir  = "/sys/class/power_supply"
	DefaultStateDir   = "/var/lib/lys-power"
	DefaultRuntimeDir = "/run/battery-charge"
	DefaultIIODir     = "/sys/bus/iio/devices"
	DefaultDevDir     = "/dev"
)
View Source
const (
	BaseStart = 75
	BaseEnd   = 80
	FullStart = 95
	FullEnd   = 100
)

Charge thresholds in percent of full capacity. The battery holds between BaseStart and BaseEnd while docked, and charges to FullStart..FullEnd while a top-up window is open or a charge-to-full request is pending.

View Source
const (
	// TopupWindowMin is how many minutes before the predicted unplug the
	// ceiling rises to full.
	TopupWindowMin = 120
	// MinSamples is the fewest unplug records from which a prediction is
	// made. Below that the manager holds the base thresholds.
	MinSamples = 3
	// HistMax caps the unplug log so a stale habit ages out of the model.
	HistMax = 60
	// Tick is how soon the daemon retries a failed evaluation, and how
	// often it checks the power source when no UPower signals reach it.
	Tick = time.Minute
	// BusTimeout bounds connecting to the system bus.
	BusTimeout = 5 * time.Second
)
View Source
const (
	DarkLux           = 1.0
	BrightLux         = 3000.0
	BrightnessFloor   = 5.0
	BrightnessCeiling = 100.0
	// MinLux is the least illuminance the smoothing works with, so a
	// sensor reading 0 in the dark keeps the logarithm finite.
	MinLux = 0.1
	// SmoothingTau is the time constant of the moving average of log
	// illuminance.
	SmoothingTau = 30 * time.Second
	// HysteresisPercent is how far the target must be from the current
	// level before the backlight moves.
	HysteresisPercent = 6.0
	// TransitionSteps writes, TransitionStep apart, carry the backlight to
	// a new level.
	TransitionSteps = 15
	TransitionStep  = 100 * time.Millisecond
	// SensorInterval is how often an ambient light sensor is read, and
	// CameraInterval how often the camera is switched on to estimate the
	// light when there is no sensor.
	SensorInterval = 2 * time.Second
	CameraInterval = time.Minute
)

Automatic brightness. The backlight follows the room's illuminance along a curve linear in log lux, from BrightnessFloor percent at or below DarkLux to BrightnessCeiling percent at or above BrightLux.

View Source
const (
	CameraSettleFrames  = 10
	CameraDiscardFrames = 3
	CameraBrackets      = 6
	CameraFrame         = 2 * time.Second
	CameraMaxExposure   = 2000
	CameraLumaLow       = 30.0
	CameraLumaTarget    = 110.0
	CameraLumaHigh      = 210.0
	CameraLuxScale      = 900.0
)

The camera estimate. The camera's auto exposure settles over CameraSettleFrames frames; its exposure is then held manually at its default gain and bracketed, at most CameraBrackets times, until a frame's mean luma lies within CameraLumaLow..CameraLumaHigh, aiming at CameraLumaTarget; CameraDiscardFrames frames are dropped after each exposure change, and no frame may take longer than CameraFrame. No exposure is longer than CameraMaxExposure exposure_absolute units, so a capture in the dark stays short. CameraLuxScale converts luma per exposure_absolute unit (100 µs) to lux, an approximation for a typical laptop camera.

Variables

View Source
var LegacyStateDirs = [...]string{
	"/var/lib/adaptive-power-manager",
	"/var/lib/power-source",
}

LegacyStateDirs are where lys-power's predecessors kept their state, newest first: adaptive-power-manager, and the bash policy before it. The first unplug history found is adopted on first run so the prediction does not start from scratch.

Functions

func HistoryIn

func HistoryIn(dir string) string

HistoryIn is the unplug log of the state directory dir.

Types

type Config

type Config struct {
	SupplyDir  string
	StateDir   string
	RuntimeDir string
	// IIODir lists the IIO devices an ambient light sensor is looked for
	// among, and DevDir holds the camera nodes.
	IIODir string
	DevDir string
}

Config is the resolved configuration.

func Load

func Load() Config

Load reads the configuration, applying LYS_POWER_* environment overrides.

func (Config) FullNowPath

func (c Config) FullNowPath() string

FullNowPath is the charge-to-full request flag.

func (Config) HistoryPath

func (c Config) HistoryPath() string

HistoryPath is the unplug log.

func (Config) LastACPath

func (c Config) LastACPath() string

LastACPath remembers the previous AC state for edge detection.

Jump to

Keyboard shortcuts

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