Here’s the script I mentioned. Full credit goes to mrsnyds who developed the original version; I simply consolidated his version into a single script and streamlined the code. You’ll see that the calculations to determine the optimal refresh interval and incremental brightness change take several lines of code.
However, if someone knows of a way to simplify it even further, and add color_temperature, then it would be a great contribution.