battery

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetProvider

func SetProvider(p Provider)

Types

type BatteryInfo

type BatteryInfo struct {
	Level           float64 `json:"level"`
	Charging        bool    `json:"charging"`
	ChargingTime    float64 `json:"chargingTime"`
	DischargingTime float64 `json:"dischargingTime"`
}

BatteryInfo mirrors the web Battery Status API: Level is 0..1, and the time fields are seconds with -1 meaning unknown.

func GetBatteryInfo

func GetBatteryInfo() (*BatteryInfo, error)

type Provider

type Provider interface {
	GetBatteryInfo() (*BatteryInfo, error)
}

Provider is a native battery backend. On mobile the shell registers one via SetProvider; on desktop the built-in platform implementation is used when no provider is set.

Jump to

Keyboard shortcuts

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