Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListPowerDevices ¶
func ListPowerDevices() []string
ListPowerDevices returns a string slice containing every power device available as provided by upower -e.
Types ¶
type Battery ¶
type Battery struct { Present bool Rechargeable bool State string WarningLevel string Energy Energy EnergyRate Watt Voltage Voltage ChargeCycles string TimeToEmpty time.Duration TimeToFull time.Duration Technology string IconName string }
Battery holds the specific information of the battery, such as its current state, if it's rechargeable, its voltage, technology used, and time to empty or full.
type BatteryInfo ¶
type BatteryInfo struct { SrcDevice string NativePath string Vendor string Model string Serial uint64 PowerSupply bool Updated time.Time HasHistory bool Statistics bool Battery Battery History []History }
BatteryInfo holds the general information of the battery, such as its model, vendor, serial, among others.
func NewForDefaultDevice ¶
func NewForDefaultDevice() (*BatteryInfo, error)
NewForDefaultDevice returns a *BatteryInfo for the default device, which is the one that ends with BAT#, where # is a number.
The following error types may be returned: *DefaultDeviceNotFoundError, *InvalidDeviceError, *CommandError.
func NewForDevice ¶
func NewForDevice(device string) (*BatteryInfo, error)
NewForDevice constructs a new *BatteryInfo for the given device. The device can be acquired with ListPowerDevices. Alternatively, if something wrong happens when fetching or parsing the battery information, an error may be returned.
The following error types may be returned: *InvalidDeviceError, *CommandError.
func (*BatteryInfo) Update ¶
func (bi *BatteryInfo) Update() (*BatteryInfo, error)
Update returns a new *BatteryInfo by re-parsing the battery information as done by NewForDevice.
Possible returnable errors are the same as for NewForDevice().
type CommandError ¶
func (*CommandError) Error ¶
func (e *CommandError) Error() string
func (*CommandError) Unwrap ¶
func (e *CommandError) Unwrap() error
type DefaultDeviceNotFoundError ¶
type DefaultDeviceNotFoundError struct{}
func (*DefaultDeviceNotFoundError) Error ¶
func (*DefaultDeviceNotFoundError) Error() string
type Energy ¶
type Energy struct {
Current, Empty, Full, FullDesign WattHour
Percentage, Capacity Percentage
}
Energy holds the information of the energy of the battery, as well as its current percentage and capacity.
type InvalidDeviceError ¶
type InvalidDeviceError struct {
Name string
}
func (*InvalidDeviceError) Error ¶
func (e *InvalidDeviceError) Error() string
type Percentage ¶
type Percentage float32
func (Percentage) String ¶
func (p Percentage) String() string