power

package
v0.0.0-...-c5429dd Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: GPL-3.0 Imports: 31 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
	PowerSavingModeAutoBatteryPercent    uint32
	Mode                                 string
}

type DSPCMode

type DSPCMode string
const (
	DSPCPerformance DSPCMode = "performance"
	DSPCBalance     DSPCMode = "balance"
	DSPCSaving      DSPCMode = "saving"
	DSPCLowBattery  DSPCMode = "lowbat"
)

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

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"`

	// 开启自动节能模式电量的百分比值
	PowerSavingModeAutoBatteryPercent uint32 `prop:"access:rw"`

	// 开启节能模式时保存的数据
	PowerSavingModeBrightnessData string `prop:"access:rw"`

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

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

	// 是否支持Boost
	IsHighPerformanceSupported bool

	// 是否支持平衡模式
	IsBalanceSupported bool

	// 是否支持节能模式
	IsPowerSaveSupported bool

	// 是否支持切换性能模式
	SupportSwitchPowerMode bool `prop:"access:rw"`
	// 当前模式
	Mode string

	// 是否在启动阶段,启动阶段不允许调节亮度; 若在启动阶段切换模式后(切节能模式降低亮度),可以调节亮度.
	IsInBootTime bool
	// 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