Documentation
¶
Overview ¶
Package backlight is the kernel's backlights as the lys apps share them: sysfs enumeration and reads, logind's SetBrightness as the write path with a direct sysfs fallback, and a watch that ticks whenever a level may have changed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Dir = "/sys/class/backlight"
Dir is the sysfs class directory of backlight devices; a var so tests can repoint it at a fake tree.
var ErrClosed = errors.New("backlight: source closed")
ErrClosed is Subscribe on a closed Broadcast.
Functions ¶
func AveragePercentage ¶
AveragePercentage is the mean level across devices, false when there is none.
Types ¶
type Broadcast ¶
type Broadcast struct {
// contains filtered or unexported fields
}
Broadcast fans change ticks out to subscribers, coalescing the ticks a slow subscriber has not taken yet into one.
func (*Broadcast) Close ¶
func (b *Broadcast) Close()
Close ends every subscription; later Subscribes fail with ErrClosed.
type Device ¶
Device is one backlight snapshot: its level against its maximum in raw units, and the DRM connector it is wired to, "" for none.
func Enumerate ¶
func Enumerate() []Device
Enumerate lists every backlight device that reads; an unreadable class directory yields an empty list.
func ReadDevice ¶
ReadDevice reads one device's snapshot from sysfs.
func (Device) Percentage ¶
Percentage maps the raw level onto 0..100.
type Source ¶
type Source interface {
// Devices returns the current snapshots.
Devices(ctx context.Context) ([]Device, error)
// Subscribe ticks whenever any device's level may have changed.
// The channel closes when ctx completes; stop releases the watch.
Subscribe(ctx context.Context) (<-chan struct{}, func(), error)
// Set applies a percentage to one device, clamped to 0..100.
Set(ctx context.Context, name string, percent float64) error
}
Source enumerates, watches and sets backlights.
type Sysfs ¶
type Sysfs struct {
// contains filtered or unexported fields
}
Sysfs is the backlights under Dir as a Source: read from sysfs, written through logind with a sysfs fallback, and watched through inotify, the kernel's backlight uevents and a drift probe.
func NewSysfs ¶
NewSysfs starts the watch. system is the system bus logind's writes go over, and stays the caller's; nil writes through sysfs alone. A missing inotify or uevent socket degrades to the drift probe instead of failing.
type Type ¶
type Type uint8
Type distinguishes firmware, platform and raw backlights, and external monitors driven over DDC/CI.
func TypeFromSysfs ¶
TypeFromSysfs parses the sysfs type attribute; unknown values are Raw.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package backlighttest fakes the sysfs backlight class directory for tests of code that reads or writes backlights.
|
Package backlighttest fakes the sysfs backlight class directory for tests of code that reads or writes backlights. |