Skip to content

fix(backlight): read sysfs brightness directly - #128

Open
Ed-web-d wants to merge 1 commit into
FedeDP:masterfrom
Ed-web-d:fix/backlight-sysfs-read
Open

Ed-web-d wants to merge 1 commit into
FedeDP:masterfrom
Ed-web-d:fix/backlight-sysfs-read

Conversation

@Ed-web-d

Copy link
Copy Markdown

Summary

Read the sysfs backlight value directly instead of through libudev's cached
sysattr value.

Root cause

sysfs.c get() calls udev_device_get_sysattr_value(dev, "brightness").
libudev caches sysfs attribute values per udev_device; after the smooth
transition writes a new brightness, get() still returns the old value.
next_backlight_pct() therefore keeps computing from the stale value and
never reaches the target.

On intel_backlight this is visible as a 1.00/0.95 ping-pong (and flooding
the journal) when requesting e.g. 0.5 with step=0.01, wait=10ms.

Note: isolate this from GNOME's own ambient auto-brightness by disabling
org.gnome.settings-daemon.plugins.power ambient-enabled first; otherwise
two writers are involved. This is not the same issue as #124.

Changes

  • Read <syspath>/brightness with open()/read() in get().

Testing

With GNOME ambient disabled, Backlight2.Set 0.5 0.01 10 now walks
smoothly from 1.0 to 0.5 and stops; before it oscillated between 1.00 and
0.95 forever. Fedora 45, MacBookPro12,1, kernel 7.3.4.

udev_device_get_sysattr_value() caches sysfs values per udev_device.
The smooth transition loop calls get() after every write, so it keeps
seeing the old brightness and never reaches the requested target; on
intel_backlight this shows up as a 1.00/0.95 ping-pong.

Read /sys/class/backlight/<dev>/brightness with open/read instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant