yuichiro-naito / asmctl

Apple System Management Controller
BSD 2-Clause "Simplified" License
3 stars 1 forks source link

Consider not lowering brightness if using `acpi` and ac power is enabled. #18

Open MegaManSec opened 1 month ago

MegaManSec commented 1 month ago

At the moment, if you are using battery and your backlight_current_level=76 and backlight_economy_level=76 and backlight_full_level=40, and you plug in the ac adapter, your current brightness will be changed to 40 -- lower than what it is currently without the adapter.

My suggestion is:

  1. Do not lower the brightness if asmctl [video|key] acpi is used and hw.acpi.acline=1.
  2. Do not raise the brightness is asmctl [video|key] acpi is used and hw.acpi.acline=0.

In both cases it should just set the correct economy/full level to the current level.

yuichiro-naito commented 4 weeks ago

Yeah, I can see similar backlight control on MacOS. Probably they control more carefully. I don't think it's possible to reproduce the same. Your idea looks reasonable for me.

yuichiro-naito commented 4 weeks ago

The asmctl code is old and cluttered. I'm going to rewrite and implement your idea.

MegaManSec commented 4 weeks ago

Yeah, I agree with you. I don't have a MacOS system to test, but I think they control it using the ambient light detected from the macbook as well -- e.g. if the room is really bright and you disconnect the power adapter, it won't lower the brightness so you can't even see the screen.

I think it's not possible for asmctl to reliably reproduce this; I can't even seem to retrieve the ambient light :

$ sysctl -ad dev.asmc.0.temp.ALSL 
dev.asmc.0.temp.ALSL: Ambient Light
$ sysctl -a dev.asmc.0.temp.ALSL 
dev.asmc.0.temp.ALSL: 0

But any improvements, I'm grateful for:)

yuichiro-naito commented 1 week ago

I implemented the backlight control policy on an ACPI event. Could you test the master branch?

MegaManSec commented 5 days ago

seems to work for me

yuichiro-naito commented 1 day ago

Thanks for testing. I'll implement adjustments depending on the ambient light if a nice idea comes to my mind.