Documentation
¶
Overview ¶
Package brightness is the shell's brightness control: the kernel's backlights from desktop/service/backlight, external monitors over DDC/CI (ddc.go) re-scanned on DRM hotplug, the outputs each drives (output.go), and the shell's brightness daemon.
Index ¶
- Constants
- Variables
- func AveragePercentage(devices []Device) (float64, bool)
- func ResumeAuto(ctx context.Context, conn *dbus.Conn) error
- func SetOutput(ctx context.Context, src Source, output string, change Change, floor float64) (float64, error)
- type Auto
- type Change
- type Control
- type Daemon
- type Device
- type Source
- type System
- type Type
Constants ¶
const ( TypeRaw = backlight.TypeRaw TypeFirmware = backlight.TypeFirmware TypePlatform = backlight.TypePlatform TypeDDC = backlight.TypeDDC )
Device types.
const ( ServiceName = "dev.stubbe.lys.Brightness1" ServicePath = dbus.ObjectPath("/dev/stubbe/lys/Brightness") )
ServiceName and ServicePath are dev.stubbe.lys.Brightness1, which `lys-shell brightness` drives.
Variables ¶
var DRMDir = drmconn.Dir
DRMDir is the sysfs class directory of DRM cards and connectors; a var so tests can repoint it.
var DevDir = "/dev"
DevDir is where Linux exposes i2c bus nodes; a var so tests can repoint it.
var ErrAutoNotRunning = errors.New("automatic brightness is not running: nothing owns " + autobrightness.ServiceName + " on the session bus")
ErrAutoNotRunning is what ResumeAuto wraps when automatic brightness is off: nothing owns its name on the session bus.
ErrDDCUnavailable is a write to a name that is not (or no longer) a managed monitor.
var I2CAdapterDir = "/sys/bus/i2c/devices"
I2CAdapterDir lists every I²C adapter as a link into its device tree; a var so tests can repoint it.
Functions ¶
func AveragePercentage ¶
AveragePercentage is the mean level across devices: what the bar label and the OSD show, since a brightness action drives every device at once. False when there is none.
func ResumeAuto ¶
ResumeAuto hands the backlight back to automatic brightness on conn, which then follows the room's light again; ErrAutoNotRunning when it is off.
Types ¶
type Auto ¶
type Auto struct {
// contains filtered or unexported fields
}
Auto follows automatic brightness on a session bus: its State on each PropertiesChanged of whichever connection owns its name, read again each time the name gains an owner, and ControlManual while nobody owns it.
func FollowAuto ¶
FollowAuto starts following automatic brightness on conn. failed is told of each state that could not be read or understood, which leaves the control as it was.
type Change ¶
type Change struct {
// contains filtered or unexported fields
}
Change is a validated brightness request in whole percent: an absolute level in 0..=100 or a signed step from the current level.
func ParseChange ¶
ParseChange reads "N", "+N" or "-N" with N in ASCII digits.
func (Change) IsRelative ¶
IsRelative reports whether the change is a step.
type Control ¶
type Control uint8
Control is who sets the backlight: the user alone while automatic brightness is off, or automatic brightness, following the room's light or paused by a manual change.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the dev.stubbe.lys.Brightness1 object: it changes the shell's own source, so the bar and the OSD follow every change.
func NewDaemon ¶
NewDaemon serves src; focused names the focused output and floor is the lowest level a change may leave.
type Device ¶
Device is one backlight or DDC/CI monitor snapshot.
func ForOutput ¶
ForOutput picks the devices that drive output: the backlights and DDC/CI monitors wired to its connector, else, for an internal panel, the backlights wired to no connector. Of several backlights only the best kind is kept (firmware, then platform, then raw), as the kernel's backlight ABI advises.
type System ¶
type System struct {
// contains filtered or unexported fields
}
System is the real source: the kernel's backlights, plus, when external monitors are enabled, DDC/CI monitors found by a detached scan and re-scanned on DRM hotplug.
func NewSystem ¶
NewSystem starts the source. external enables DDC/CI discovery (the enable-external key); the first scan runs detached so internal panels are usable at once. system is the system bus logind's writes go over, and stays the caller's; nil writes through sysfs. A missing uevent socket degrades to no DDC hotplug instead of failing.
func (*System) Close ¶
Close stops the watchers and waits for the goroutines; later calls are no-ops.
func (*System) Devices ¶
Devices reads every sysfs device, then the DDC monitors from their cached levels (a DDC read is too slow to make per refresh), each at the level a queued write is heading to.
func (*System) Set ¶
Set applies a clamped percentage. A DDC monitor's write is handed to its writer goroutine and Set returns at once: DDC I/O takes tens of milliseconds a transaction, and a slider drag coalesces to the latest value instead of queueing every step. Write failures are logged.
func (*System) SetExternal ¶
SetExternal follows the enable-external key: on starts a detached DDC scan, off closes every i2c bus held and scans no more until it is on again.