battery

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package battery provides battery information for the host and connected devices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasReadableBattery

func HasReadableBattery() bool

HasReadableBattery reports whether collection currently finds a readable battery.

Types

type Battery added in v0.18.8

type Battery struct {
	Name                  string
	Percent               uint8
	State                 uint8
	FullChargeCapacity    uint64
	HasFullChargeCapacity bool
	System                bool
}

Battery is a readable battery reported by the operating system.

func GetBatteryStats

func GetBatteryStats() ([]Battery, error)

GetBatteryStats re-enumerates power supplies and returns every readable battery.

func Primary added in v0.18.8

func Primary(batteries []Battery) (Battery, bool)

Primary returns the representative battery. Reported full-charge capacity wins, then system-scoped devices, then name for deterministic ties.

Jump to

Keyboard shortcuts

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