power

package
v0.0.0-...-520a03a Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SW_LID = C.SW_LID
	SW_CNT = C.SW_CNT
	SW_MAX = C.SW_MAX
	EV_SW  = C.EV_SW
)

Variables

This section is empty.

Functions

func LONG

func LONG(x int) int

#define LONG(x) ((x)/BITS_PER_LONG)

func NBITS

func NBITS(x int) int

NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)

func OFF

func OFF(x int) int

#define OFF(x) ((x)%BITS_PER_LONG)

Types

type AC

type AC struct {
	// contains filtered or unexported fields
}

type Battery

type Battery struct {
	PropsMu   sync.RWMutex
	SysfsPath string
	IsPresent bool

	Manufacturer string
	ModelName    string
	SerialNumber string
	Name         string
	Technology   string

	Energy           float64
	EnergyFull       float64
	EnergyFullDesign float64
	EnergyRate       float64

	Voltage     float64
	Percentage  float64
	Capacity    float64
	Status      battery.Status
	TimeToEmpty uint64
	TimeToFull  uint64
	UpdateTime  int64
	// contains filtered or unexported fields
}

func (*Battery) GetExportedMethods

func (v *Battery) GetExportedMethods() dbusutil.ExportedMethods

func (*Battery) GetInterfaceName

func (*Battery) GetInterfaceName() string

func (*Battery) Refresh

func (bat *Battery) Refresh()

type Config

type Config struct {
	PowerSavingModeEnabled               bool
	PowerSavingModeAuto                  bool
	PowerSavingModeAutoWhenBatteryLow    bool
	PowerSavingModeBrightnessDropPercent uint32
	Mode                                 string
}

type CpuHandler

type CpuHandler struct {
	// contains filtered or unexported fields
}

func (*CpuHandler) GetAvailableGovernors

func (cpu *CpuHandler) GetAvailableGovernors(force bool) (map[string]bool, error)

func (*CpuHandler) GetGovernor

func (cpu *CpuHandler) GetGovernor(force bool) (string, error)

func (*CpuHandler) SetGovernor

func (cpu *CpuHandler) SetGovernor(governor string) error

type CpuHandlers

type CpuHandlers []CpuHandler

func NewCpuHandlers

func NewCpuHandlers() *CpuHandlers

func (*CpuHandlers) GetAvailableGovernors

func (cpus *CpuHandlers) GetAvailableGovernors() (map[string]bool, error)

func (*CpuHandlers) GetBoostEnabled

func (cpus *CpuHandlers) GetBoostEnabled() (bool, error)

func (*CpuHandlers) GetGovernor

func (cpus *CpuHandlers) GetGovernor() (string, error)

func (*CpuHandlers) IsBoostFileExist

func (cpus *CpuHandlers) IsBoostFileExist() bool

func (*CpuHandlers) SetBoostEnabled

func (cpus *CpuHandlers) SetBoostEnabled(enabled bool) error

func (*CpuHandlers) SetGovernor

func (cpus *CpuHandlers) SetGovernor(governor string) error

type Daemon

type Daemon struct {
	*loader.ModuleBase
	// contains filtered or unexported fields
}

func NewDaemon

func NewDaemon(logger *log.Logger) *Daemon

func (*Daemon) GetDependencies

func (d *Daemon) GetDependencies() []string

func (*Daemon) Start

func (d *Daemon) Start() (err error)

func (*Daemon) Stop

func (d *Daemon) Stop() error

func (*Daemon) WaitEnable

func (d *Daemon) WaitEnable()

type InputEvent

type InputEvent struct {
	Time  syscall.Timeval // time in seconds since epoch at which event occurred
	Type  uint16          // event type - one of ecodes.EV_*
	Code  uint16          // event code related to the event type
	Value int32           // event value related to the event type
}

func (*InputEvent) String

func (ev *InputEvent) String() string

Get a useful description for an input event. Example:

event at 1347905437.435795, code 01, type 02, val 02

type Manager

type Manager struct {
	PropsMu      sync.RWMutex
	OnBattery    bool
	HasLidSwitch bool
	// battery display properties:
	HasBattery         bool
	BatteryPercentage  float64
	BatteryStatus      battery.Status
	BatteryTimeToEmpty uint64
	BatteryTimeToFull  uint64
	// 电池容量
	BatteryCapacity float64

	// 开启和关闭节能模式
	PowerSavingModeEnabled bool `prop:"access:rw"`

	// 自动切换节能模式,依据为是否插拔电源
	PowerSavingModeAuto bool `prop:"access:rw"`

	// 低电量时自动开启
	PowerSavingModeAutoWhenBatteryLow bool `prop:"access:rw"`

	// 开启节能模式时降低亮度的百分比值
	PowerSavingModeBrightnessDropPercent uint32 `prop:"access:rw"`

	// CPU频率调节模式,支持powersave和performance
	CpuGovernor string

	// CPU频率增强是否开启
	CpuBoost bool

	// 是否支持Boost
	IsHighPerformanceSupported bool

	// 当前模式
	Mode string
	// contains filtered or unexported fields
}

https://www.kernel.org/doc/Documentation/power/power_supply_class.txt

func (*Manager) GetBatteries

func (m *Manager) GetBatteries() (batteries []dbus.ObjectPath, busErr *dbus.Error)

func (*Manager) GetExportedMethods

func (v *Manager) GetExportedMethods() dbusutil.ExportedMethods

func (*Manager) GetInterfaceName

func (*Manager) GetInterfaceName() string

func (*Manager) LockCpuFreq

func (m *Manager) LockCpuFreq(governor string, lockTime int32) *dbus.Error

func (*Manager) Refresh

func (m *Manager) Refresh() *dbus.Error

func (*Manager) RefreshBatteries

func (m *Manager) RefreshBatteries() *dbus.Error

func (*Manager) RefreshMains

func (m *Manager) RefreshMains() *dbus.Error

func (*Manager) SetCpuBoost

func (m *Manager) SetCpuBoost(enabled bool) *dbus.Error

func (*Manager) SetCpuGovernor

func (m *Manager) SetCpuGovernor(governor string) *dbus.Error

func (*Manager) SetMode

func (m *Manager) SetMode(mode string) *dbus.Error

Jump to

Keyboard shortcuts

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