steel99xl / Mac-like-automatic-brightness

A simple script to provide a "Mac" like automatic brightness adjustemnt/ animation
17 stars 4 forks source link

Adding new script and service example #4

Closed Theluga closed 11 months ago

Theluga commented 11 months ago

I figure out how to proper pull haha sorry for the confusion

The darker mode, when the illuminance is less than 1 i.e. 0, it will go to the target brightness that is 1. The target can be easily changed.

If the file AB.offset have 0 as value. Darker mode is activated and setting brightness will reset to target value 1 when illuminance is less than 1. if the file has value of 1, it will be the normal mode and the screen brightness can be adjusted until the illuminance sensor changes.

easier to change variables and places and chmod 666 /tmp/AB.offset for the user to change modes when script is running as root (systemd service) darker mode as default with normal mode done by typing "echo 1 > /tmp/AB.offset"

they are in autobrightness.sh

steel99xl commented 11 months ago

Thank you I fixed the typo, but the AB.offset is to offset your sensors reading so you can still manually control the screen brightness with a bound key like on a MacBook (minus being able to turn the back light off, but it does get darker that the allowed minimum on my 2017 macbook )

also 'smoothly_decrease_brightnes' doesn't make sens to be called right after the screen brightness has already been adjusted by the first pass if the brightness is below a specific value it would operate slower than just calling that as an alternative at the top in a switch of if statement (also means a minimum time of 2 seconds before the screen can update again instead of one just based on the loop)

I will gladly take you autobrightness.service as a commit

Theluga commented 11 months ago

You are absolutely right. It doesn't! And it is very inefficient and loses the ability to set brightness... I'm sorry... Bash still is an esoteric language to me. Haha

The reason is that I didn't find a STD That completely worked. If I set some it becomes too bright in dark environments and if I set another it becomes too dim in bright environments... So I created this function to decrease the brightness outside the offset but... I didn't think it was so bad.

What I am thinking of doing is to create two variables to calibrate the sensor (I saw another issue with float stds...)

My screen goes from 1 to 937. And I would want to set a maximum dark environment to calibrate my sensor with minimum illuminance to go to minimum brightness. And set a maximum illuminance to go to maximum brightness.

For example: Minimum illuminance: 3 (some folks might have a very sensitive als) Illuminance of 3 or less: brightness will be 1 (the minimum set on the script) .

Maximum illuminance: 800 (some folks might have a very dim screen) Illuminance of 800 or more: brightness will be 937 (maximum set on the script)

Literally a calibration on the script side.

With a cutout on these limits, offset will still be used to translate the values. I don't know how the STD variable will be affected or if it will continue working as expected.

I don't know if it's feasible, I will try in the next weeks and if possible, I would like to ask for help after some roadblocks.

Thank you for everything!

Theluga commented 11 months ago

Could you please see if its good now? Now I get all the range of brightness even when totally dark. Before it never went to the minimum brightness no matter what I did.

Now it has everything set and working even autodetection of als (I don't know what would happen if there was two or more als devices at the same time)

If you want, you can also add my STD as 20.

Theluga commented 11 months ago

Hello, Now there is no problem if there are more than 2 such devices. It will use the first device as default, the user can change it if he wants another one.

Autodetection is now working. The als path is now saved on the variable, not searching everything at every call.

Is there another place to fix before merging?