macos-brightness icon indicating copy to clipboard operation
macos-brightness copied to clipboard

Brightness Not Persisting After Wake Up from Sleep

Open DanAykroyd256 opened this issue 4 years ago • 5 comments

Hi, I hope you are doing well.

I've been having an issue with nriley/brightness and I've found out your tool to try to see how it works here, but I still find the same issue.

I've posted about this issue at nriley's GitHub too. I've noticed that the brightness I set through the command line using his and your version of brightness doesn't persist after a sleep-wake up cycle.

When I wake up the MacBook Pro (Mojave) from sleep, the brightness fades out to whatever setting I've manually used before by using the Touchbar brightness slider, instead of staying at the level I've set up with brightness. This is 100% reproducible on my end and happens every time I return from sleep.

Do you have any idea on what might be going on?

Thanks in advance for your help.

DanAykroyd256 avatar Apr 23 '20 05:04 DanAykroyd256

Hi @DanAykroyd256, thanks, I'm doing just fine :). Regarding your issue, it looks like it has to do with the "Automatically adjust brightness" setting. I can reproduce the issue when that setting is enabled, but everything works as expected when it's disabled (I always keep it disabled).

My guess is that when the setting is adjusted via System Preferences, the setting also propagates to the part that is responsible for managing the automatic brightness. But the private API used here does not, unfortunately.

mafredri avatar May 07 '20 16:05 mafredri

I managed to reproduce the issue easily btw, with "Automatically adjust brightness" enabled, no need for sleep even. First set brightness (via slider) to 100, then use cli to set to 60, and then block the light sensor with your finger (and it jumps back to 100).

I took a look but couldn't find any functions other than CoreDisplay_Display_SetAutoBrightnessIsEnabled, but it seems to have no effect :/.

mafredri avatar May 07 '20 18:05 mafredri

Thanks for your reply mafredri!

That's a nice find; don't even need to sleep and covering the sensor throws out the same behavior. I've noticed that if:

  • I manually disable the "Automatically adjust brightness" checkbox in Display settings
  • Use the brightness CLI to set a certain level
  • Manually re-enable the "Automatically adjust brightness" checkbox in Display settings

Then the brightness level stays put and doesn't jump back to the previous value as it happens while changing brightness through the CLI with that checkbox enabled.

So, I am wondering, is there any API (or AppleScript) way that you know to toggle that checkbox through code instead of manually? If so, a workaround would be to disable it, use your brightness CLI to set a desired level and then reenable that checkbox.

Thanks again!

DanAykroyd256 avatar May 08 '20 01:05 DanAykroyd256

Hi @mafredri, do you have any updates on this?

Thanks.

DanAykroyd256 avatar Jul 23 '20 09:07 DanAykroyd256

@DanAykroyd256 no, unfortunately. I did a bit of digging a while back but couldn't figure it out.

mafredri avatar Oct 30 '20 21:10 mafredri