Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorServiceBrightness::BrightnessHost Class Reference

Enumerates the brightness-controllable backlights under a sysfs root. More...

#include <PhosphorServiceBrightness/BrightnessHost.h>

Inheritance diagram for PhosphorServiceBrightness::BrightnessHost:
[legend]

Signals

void deviceAdded (PhosphorServiceBrightness::BrightnessDevice *device)
 Sysfs devices are added synchronously at construction; external displays (DDC/CI) arrive asynchronously after the worker enumerates them.
void deviceRemoved (PhosphorServiceBrightness::BrightnessDevice *device)
 The counterpart to deviceAdded, for dynamic sources that can drop a device at runtime.
void deviceCountChanged ()

Public Member Functions

 BrightnessHost (QObject *parent=nullptr)
 Production wiring: the real sysfs root (/sys), the system bus, and the logind session resolved from the calling process.
 BrightnessHost (QString sysfsRoot, QDBusConnection connection, QString service, QString sessionPath, QObject *parent=nullptr)
 Injectable wiring for tests / advanced consumers.
 ~BrightnessHost () override
QList< BrightnessDevice * > devices () const
int deviceCount () const
PhosphorServiceBrightness::BrightnessDevice * deviceAt (int index) const

Detailed Description

Enumerates the brightness-controllable backlights under a sysfs root.

Scans <root>/class/backlight (display panels) and the kbd_backlight entries under <root>/class/leds (keyboard backlights); every other /sys/class/leds entry is an indicator, not a brightness control, and is skipped. The device set is enumerated once at construction (backlights do not hotplug); per-device values update live via each device's file watcher.

Writes route through logind, so the host resolves the session object path (asynchronously: GetSession for XDG_SESSION_ID, falling back to GetSessionByPID when that is unset; or injected) and hands it to the devices. Inert when the sysfs root is absent (empty list, no crash); read-only when no logind session is bound.

The sysfs root and the (connection, service, sessionPath) are injectable so the whole read + write surface is testable against a fake sysfs tree and a fake logind with no root and no daemon.

Constructor & Destructor Documentation

◆ BrightnessHost() [1/2]

PhosphorServiceBrightness::BrightnessHost::BrightnessHost ( QObject * parent = nullptr)
explicit

Production wiring: the real sysfs root (/sys), the system bus, and the logind session resolved from the calling process.

◆ BrightnessHost() [2/2]

PhosphorServiceBrightness::BrightnessHost::BrightnessHost ( QString sysfsRoot,
QDBusConnection connection,
QString service,
QString sessionPath,
QObject * parent = nullptr )

Injectable wiring for tests / advanced consumers.

A non-empty sessionPath is used as-is; an empty one is resolved asynchronously from XDG_SESSION_ID (or the calling process via GetSessionByPID when that is unset), when connection is connected.

◆ ~BrightnessHost()

PhosphorServiceBrightness::BrightnessHost::~BrightnessHost ( )
override

Member Function Documentation

◆ deviceAdded

void PhosphorServiceBrightness::BrightnessHost::deviceAdded ( PhosphorServiceBrightness::BrightnessDevice * device)
signal

Sysfs devices are added synchronously at construction; external displays (DDC/CI) arrive asynchronously after the worker enumerates them.

◆ deviceAt()

PhosphorServiceBrightness::BrightnessDevice * PhosphorServiceBrightness::BrightnessHost::deviceAt ( int index) const
nodiscard

◆ deviceCount()

int PhosphorServiceBrightness::BrightnessHost::deviceCount ( ) const
nodiscard

◆ deviceCountChanged

void PhosphorServiceBrightness::BrightnessHost::deviceCountChanged ( )
signal

◆ deviceRemoved

void PhosphorServiceBrightness::BrightnessHost::deviceRemoved ( PhosphorServiceBrightness::BrightnessDevice * device)
signal

The counterpart to deviceAdded, for dynamic sources that can drop a device at runtime.

The current sources are stable for the host's lifetime (sysfs is enumerated once; DDC/CI enumeration is one-shot), so the host does not emit this today; consumers (e.g. BrightnessDeviceModel) handle it so a future hot-removal source needs no consumer changes.

◆ devices()

QList< BrightnessDevice * > PhosphorServiceBrightness::BrightnessHost::devices ( ) const
nodiscard

The documentation for this class was generated from the following file:
  • phosphor-service-brightness/include/PhosphorServiceBrightness/BrightnessHost.h