power

package
v1.30.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package power reports the host's power state so lerd can back off work that is cheap on mains and expensive on a laptop running from its battery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State int

State is how the host is currently powered, ordered by how much lerd should hold back.

const (
	// Mains is plugged in with no energy-saving mode engaged.
	Mains State = iota
	// Battery is running from the battery.
	Battery
	// LowPower is an explicit user request to conserve energy (macOS Low Power
	// Mode, the power-saver profile on Linux). It outranks Battery: the
	// setting can be switched on while plugged in, and when it is, the user has
	// asked for less background work regardless of the power source.
	LowPower
)

func Current

func Current() State

Current reports how the host is powered. Anything undeterminable reports Mains: the conservative answer keeps the normal cadence rather than degrading behaviour on a desktop, a VM, or a container that never had a battery.

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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