Re: [PATCH 1/2] efi: Save Brightness using EFI on Macs

Hans de Goede
2026-02-09T08:46:47Z

Hi,

On 8-Feb-26 14:16, Lukas Wunner wrote:
> On Sun, Feb 08, 2026 at 11:45:55AM +0100, Hans de Goede wrote:
>> I was already worried about the shutdown approach on v1,
>> but did not say anything since I'm not that familiar
>> with apple hw and other apple code is already doing
>> something similar.
>
> Yes, macOS saves the brightness so that it's persisted across reboots
> and can be set already by the EFI firmware, avoiding a bloom effect
> (brightness change) on handover to the OS. We want to provide the
> same seamless user experience on Linux that users have grown accustomed
> to on macOS, I think that's a reasonable thing to do.
>
>> But writing a non-volatile EFI variable every 300ms is
>> just a very very bad idea.
>
> Agreed. But what do you think about a delayed write when brightness
> is changed, so that brightness is persisted even if the OS crashes?
> Users don't change brightness that often, I can't imagine that it
> amounts to a significantly higher number of writes than if it's
> only done on shutdown.

How about saving the bootup brightness and then on shutdown
compare and store it only if it changed ?

That seems the safest approach. OS crashes should be seldom and
the brightness not getting restored will be the least of a user's
worries if those happen.

Something like this should really be written to minimize
the amount of nvram writes.

It might actually be a good idea to change the existing apply
brightness saving code in the same way.

Regards,

Hans