Skip to content

Commit ba6d8f5

Browse files
committed
backlight: track brightness changes for accurate restore_on_exit
Keep the bls map in sync with actual backlight levels so that restore_on_exit restores the last user-set brightness rather than the level recorded at startup. Skip updates during dimmed/dpms states to avoid restoring a dimmed brightness on exit. Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
1 parent 987a0c4 commit ba6d8f5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/modules/backlight.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,16 @@ static int on_bl_changed(sd_bus_message *m, UNUSED void *userdata, UNUSED sd_bus
771771

772772
DEBUG("Backlight '%s' level updated: %.2lf.\n", syspath, pct);
773773

774+
/* Keep bls map in sync for restore_on_exit, but skip dimmed/dpms states */
775+
if (!state.display_state) {
776+
char key[PATH_MAX + 1];
777+
make_valid_obj_path(key, sizeof(key), "/org/clightd/clightd/Backlight2", syspath);
778+
double *val = map_get(bls, key);
779+
if (val) {
780+
*val = pct;
781+
}
782+
}
783+
774784
/* Publish a single bl update event on multimonitor setups */
775785
if (!strcmp(backlight_interface, syspath)) {
776786
publish_bl_upd(pct, false, 0, 0);

0 commit comments

Comments
 (0)