jacob-pro / solar-screen-brightness

Automatically adjust monitor / screen brightness at night using sunrise/sunset times
GNU Lesser General Public License v3.0
54 stars 4 forks source link

SSB does not adjust brightness over time #15

Closed mruac closed 2 years ago

mruac commented 2 years ago

Title. It only corrects itself when the config is reloaded. Is this supposed to smoothly change the brightness over time like Windows 10's nightshift?

https://user-images.githubusercontent.com/19784752/140910482-551ff43b-7471-4a22-aeab-64d1051f9e32.mp4

jacob-pro commented 2 years ago

So yes it is supposed to adjust brightness slowly over time, and this what the "transition minutes" means.

I.e. you have a day brightness set to 100 at the start, and in the status screen you will note sunset is at 19:53. Since you have transition minutes set to only 5, it means it will start decreasing brightness from 100 to 20 at ~19:51 and finish 5 minutes later at ~19:55. If you want it to adjust smoothly you would therefore need a much greater transition time.

It may also help to have a look at this drawing (sorry for the quality!)

I'm not sure however if there is some other issue with the clock / timing though, because the following things should always be true:

Would it be possible to have your log output during sunset / sunrise?

Edit: There is definitely an issue here, with your combo of config & timezone, I will investigate it and try and fix it.

mruac commented 2 years ago

This also happens at the default 40 minutes, the clock ticks over the "Changes at" time and the screen does not appear to dim at all. It only dims whenever the config is reloaded, as demonstrated.

mruac commented 2 years ago

SSB managed to start with the console running on first try this time, so I'll see what the console logs say when the time ticks over.

mruac commented 2 years ago
[2021-11-09T10:48:55Z INFO  solar_screen_brightness::lock::lock_impl] Acquired lock: solar-screen-brightness-0e9457
[2021-11-09T10:48:55Z INFO  solar_screen_brightness::config] Successfully loaded config file
[2021-11-09T10:48:55Z INFO  solar_screen_brightness::controller] Starting BrightnessController
[2021-11-09T10:48:55Z INFO  solar_screen_brightness::tray] Launching tray application
[2021-11-09T10:48:55Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 20%
[2021-11-09T10:48:55Z INFO  solar_screen_brightness::console] Showing console
[2021-11-09T10:48:55Z INFO  solar_screen_brightness::tui] Cursive thread starting[2021-11-09T10:48:55Z INFO  solar_screen_brightness::console::console_impl] Found valid PDC_hWnd in 2.47 ms
[2021-11-09T10:48:55Z INFO  solar_screen_brightness::controller::apply] Brightness applied successfully to 1 monitors
[2021-11-09T10:48:55Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 31446s
[2021-11-09T10:49:15Z INFO  solar_screen_brightness::tray] Sending close console message to tray
[2021-11-09T10:49:15Z INFO  solar_screen_brightness::console] Hiding console
[2021-11-09T13:31:42Z INFO  solar_screen_brightness::console] Showing console
[2021-11-09T13:31:48Z INFO  solar_screen_brightness::tray] Sending close console message to tray
[2021-11-09T13:31:48Z INFO  solar_screen_brightness::console] Hiding console
[2021-11-09T19:33:01Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 20%
[2021-11-09T19:33:02Z INFO  solar_screen_brightness::controller::apply] Brightness applied successfully to 1 monitors
[2021-11-09T19:33:02Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 86352s
[2021-11-09T22:14:19Z INFO  solar_screen_brightness::console] Showing console
[2021-11-09T22:14:24Z INFO  solar_screen_brightness::config] Successfully loaded config file
[2021-11-09T22:14:24Z INFO  solar_screen_brightness::controller] Applying new config
[2021-11-09T22:14:24Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 100%
[2021-11-09T22:14:24Z INFO  solar_screen_brightness::controller::apply] Brightness applied successfully to 1 monitors
[2021-11-09T22:14:24Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 40023s
[2021-11-09T22:14:27Z INFO  solar_screen_brightness::tray] Sending close console message to tray
[2021-11-09T22:14:27Z INFO  solar_screen_brightness::console] Hiding console
[2021-11-10T04:18:36Z INFO  solar_screen_brightness::tray::tray_impl] Detected session lock, ensuring dynamic brightness disabled
[2021-11-10T04:18:36Z INFO  solar_screen_brightness::controller] Disabling dynamic brightness
[2021-11-10T04:18:36Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 100%
[2021-11-10T04:18:36Z INFO  solar_screen_brightness::controller::apply] Dynamic brightness is disabled, skipping apply
[2021-11-10T04:18:36Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 104630s
[2021-11-10T05:20:40Z INFO  solar_screen_brightness::tray::tray_impl] Detected session unlock, enabling dynamic brightness
[2021-11-10T05:20:40Z INFO  solar_screen_brightness::controller] Enabling dynamic brightness
[2021-11-10T05:20:40Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 100%
[2021-11-10T05:20:40Z INFO  solar_screen_brightness::controller::apply] Brightness applied successfully to 1 monitors
[2021-11-10T05:20:40Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 100906s
[2021-11-10T10:01:39Z INFO  solar_screen_brightness::console] Showing console
[2021-11-10T10:01:51Z INFO  solar_screen_brightness::tray] Sending close console message to tray
[2021-11-10T10:01:51Z INFO  solar_screen_brightness::console] Hiding console
[2021-11-10T10:35:23Z INFO  solar_screen_brightness::console] Showing console
[2021-11-10T10:36:26Z INFO  solar_screen_brightness::config] Successfully loaded config file
[2021-11-10T10:36:26Z INFO  solar_screen_brightness::controller] Applying new config
[2021-11-10T10:36:26Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 20%
[2021-11-10T10:36:27Z INFO  solar_screen_brightness::controller::apply] Brightness applied successfully to 1 monitors
[2021-11-10T10:36:27Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 32147s
[2021-11-10T10:36:32Z INFO  solar_screen_brightness::tray] Sending close console message to tray
[2021-11-10T10:36:32Z INFO  solar_screen_brightness::console] Hiding console
[2021-11-10T10:36:57Z INFO  solar_screen_brightness::console] Showing console
[2021-11-10T10:37:03Z INFO  solar_screen_brightness::controller] Applying new config
[2021-11-10T10:37:03Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 20%
[2021-11-10T10:37:03Z INFO  solar_screen_brightness::config] Successfully saved config file
[2021-11-10T10:37:03Z INFO  solar_screen_brightness::controller::apply] Brightness applied successfully to 1 monitors
[2021-11-10T10:37:03Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 31061s
[2021-11-10T10:37:04Z INFO  solar_screen_brightness::tray] Sending close console message to tray
[2021-11-10T10:37:04Z INFO  solar_screen_brightness::console] Hiding console
[2021-11-10T14:33:24Z INFO  solar_screen_brightness::tray::tray_impl] Detected session lock, ensuring dynamic brightness disabled
[2021-11-10T14:33:24Z INFO  solar_screen_brightness::controller] Disabling dynamic brightness
[2021-11-10T14:33:24Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 20%
[2021-11-10T14:33:24Z INFO  solar_screen_brightness::controller::apply] Dynamic brightness is disabled, skipping apply
[2021-11-10T14:33:24Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 16880s
[2021-11-10T19:14:44Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 20%
[2021-11-10T19:14:44Z INFO  solar_screen_brightness::controller::apply] Dynamic brightness is disabled, skipping apply
[2021-11-10T19:14:44Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 86354s
[2021-11-10T22:29:04Z INFO  solar_screen_brightness::tray::tray_impl] Detected session unlock, enabling dynamic brightness
[2021-11-10T22:29:04Z INFO  solar_screen_brightness::controller] Enabling dynamic brightness
[2021-11-10T22:29:04Z INFO  solar_screen_brightness::controller::apply] Computed base brightness of 100%
[2021-11-10T22:29:04Z INFO  solar_screen_brightness::controller::apply] Brightness applied successfully to 1 monitors
[2021-11-10T22:29:04Z INFO  solar_screen_brightness::controller::worker] Brightness Worker sleeping for 38152s

https://user-images.githubusercontent.com/19784752/141206900-248fb85d-8eba-4e87-8930-cf24546d5f4a.mp4

Hope this helps.

For what it's worth, SSB has been running for 36 hours at this point. The video was recorded last night.

jacob-pro commented 2 years ago

@mruac I think I have figured it out So the issue is actually in the sunset calculation - instead of getting the sunset for today, it is getting the sunset for tomorrow (but only in the southern hemisphere!)

I have updated the dependency here: https://github.com/jacob-pro/solar-screen-brightness/pull/16

Please can you try 0.1.4: https://github.com/jacob-pro/solar-screen-brightness/releases/tag/0.1.4

mruac commented 2 years ago

Amazing, now that the tool is working it's working like magic! You've made a wonderful little tool for external monitors 😊