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 ¶
const ( DefaultSupplyDir = "/sys/class/power_supply" DefaultStateDir = "/var/lib/lys-power" DefaultRuntimeDir = "/run/battery-charge" DefaultIIODir = "/sys/bus/iio/devices" DefaultDevDir = "/dev" )
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.
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 )
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.
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 ¶
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 ¶
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 ¶
FullNowPath is the charge-to-full request flag.
func (Config) LastACPath ¶
LastACPath remembers the previous AC state for edge detection.