One brightness-controllable backlight: a display panel (under /sys/class/backlight) or a keyboard backlight (a kbd_backlight entry under /sys/class/leds).
More...
#include <PhosphorServiceBrightness/BrightnessDevice.h>
|
| | BrightnessDevice (QDBusConnection connection, QString service, QString sessionPath, Kind kind, QString name, QString sysfsDir, QObject *parent=nullptr) |
| | Sysfs-backed device (Display / Keyboard): reads sysfs, writes via logind.
|
| | BrightnessDevice (QString id, QString name, int brightness, int maxBrightness, std::function< void(int)> setter, QObject *parent=nullptr) |
| | External-display (DDC/CI) device.
|
| | ~BrightnessDevice () override |
| QString | id () const |
| | Stable unique identifier for addressing this device (sysfs name for backlights, I2C bus for external displays).
|
| QString | name () const |
| Kind | kind () const |
| int | brightness () const |
| int | maxBrightness () const |
| qreal | percentage () const |
| | brightness / maxBrightness in [0.0, 1.0]; 0.0 when maxBrightness is 0.
|
| void | setBrightness (int value) |
| | Set the raw brightness (clamped to [0, maxBrightness]) via logind.
|
| void | setPercentage (qreal percentage) |
| | Set brightness as a fraction in [0.0, 1.0] of maxBrightness, via logind.
|
| void | refresh () |
| | Re-read the sysfs attributes now.
|
| void | applyExternalValue (int brightness) |
| | Push a DDC read-back value for an external-display device.
|
| void | setSessionPath (const QString &sessionPath) |
| | Logind session object path used for the SetBrightness write.
|
One brightness-controllable backlight: a display panel (under /sys/class/backlight) or a keyboard backlight (a kbd_backlight entry under /sys/class/leds).
The current value is read from the sysfs brightness attribute (with max_brightness for the range); external changes (hardware keys, another app) are tracked live via a file watcher on the brightness attribute. Writes go through logind's org.freedesktop.login1.Session.SetBrightness(subsystem, name, value) so no root or udev rule is needed; the cached value is not updated optimistically (it moves when the watcher re-reads), and the write no-ops when no logind session is bound. Owned by BrightnessHost; never constructed from QML.
◆ Kind
| Enumerator |
|---|
| Display | Internal panel backlight (/sys/class/backlight).
|
| Keyboard | Keyboard backlight (*::kbd_backlight under /sys/class/leds).
|
| ExternalDisplay | External monitor over DDC/CI (libddcutil); writes do not use logind.
|
◆ BrightnessDevice() [1/2]
| PhosphorServiceBrightness::BrightnessDevice::BrightnessDevice |
( |
QDBusConnection | connection, |
|
|
QString | service, |
|
|
QString | sessionPath, |
|
|
Kind | kind, |
|
|
QString | name, |
|
|
QString | sysfsDir, |
|
|
QObject * | parent = nullptr ) |
Sysfs-backed device (Display / Keyboard): reads sysfs, writes via logind.
The sysfs device name (e.g. intel_backlight) is both the human-readable name and the stable unique id.
◆ BrightnessDevice() [2/2]
| PhosphorServiceBrightness::BrightnessDevice::BrightnessDevice |
( |
QString | id, |
|
|
QString | name, |
|
|
int | brightness, |
|
|
int | maxBrightness, |
|
|
std::function< void(int)> | setter, |
|
|
QObject * | parent = nullptr ) |
External-display (DDC/CI) device.
id is a stable unique key (the I2C bus, e.g. i2c-7); name is the monitor's model string, which is NOT unique (identical monitors share it). The range comes from the initial DDC probe; setter is invoked with the requested raw value (BrightnessHost routes it to its off-thread DDC worker), and read-backs are pushed via applyExternalValue. Keeps libddcutil / threading out of this class.
◆ ~BrightnessDevice()
| PhosphorServiceBrightness::BrightnessDevice::~BrightnessDevice |
( |
| ) |
|
|
override |
◆ applyExternalValue()
| void PhosphorServiceBrightness::BrightnessDevice::applyExternalValue |
( |
int | brightness | ) |
|
Push a DDC read-back value for an external-display device.
BrightnessHost calls this from its DDC worker's read signal; updates the cached brightness, emitting brightnessChanged on a real change.
◆ brightness()
| int PhosphorServiceBrightness::BrightnessDevice::brightness |
( |
| ) |
const |
|
nodiscard |
◆ brightnessChanged
| void PhosphorServiceBrightness::BrightnessDevice::brightnessChanged |
( |
| ) |
|
|
signal |
◆ id()
| QString PhosphorServiceBrightness::BrightnessDevice::id |
( |
| ) |
const |
|
nodiscard |
Stable unique identifier for addressing this device (sysfs name for backlights, I2C bus for external displays).
Unlike name, never collides.
◆ kind()
| Kind PhosphorServiceBrightness::BrightnessDevice::kind |
( |
| ) |
const |
|
nodiscard |
◆ maxBrightness()
| int PhosphorServiceBrightness::BrightnessDevice::maxBrightness |
( |
| ) |
const |
|
nodiscard |
◆ name()
| QString PhosphorServiceBrightness::BrightnessDevice::name |
( |
| ) |
const |
|
nodiscard |
◆ percentage()
| qreal PhosphorServiceBrightness::BrightnessDevice::percentage |
( |
| ) |
const |
|
nodiscard |
brightness / maxBrightness in [0.0, 1.0]; 0.0 when maxBrightness is 0.
◆ refresh()
| void PhosphorServiceBrightness::BrightnessDevice::refresh |
( |
| ) |
|
Re-read the sysfs attributes now.
Called by the watcher on external changes; also useful for an on-demand refresh. (Sysfs devices only; external-display values are pushed via applyExternalValue.)
◆ setBrightness()
| void PhosphorServiceBrightness::BrightnessDevice::setBrightness |
( |
int | value | ) |
|
Set the raw brightness (clamped to [0, maxBrightness]) via logind.
◆ setPercentage()
| void PhosphorServiceBrightness::BrightnessDevice::setPercentage |
( |
qreal | percentage | ) |
|
Set brightness as a fraction in [0.0, 1.0] of maxBrightness, via logind.
◆ setSessionPath()
| void PhosphorServiceBrightness::BrightnessDevice::setSessionPath |
( |
const QString & | sessionPath | ) |
|
Logind session object path used for the SetBrightness write.
Set by BrightnessHost once it resolves the session (the write is inert until then, or permanently if no session is bound).
The documentation for this class was generated from the following file: