katernet / darkmode

Set macOS dark mode and Alfred dark theme at sunset
GNU General Public License v3.0
150 stars 10 forks source link

launchd doesn't run darkmode script if solar time was missed while computer was off #4

Closed bandgeekdante closed 6 years ago

bandgeekdante commented 6 years ago

If the computer was sleeping, the StartCalendarInterval fires as soon as the computer wakes if the interval was missed, but this is not the case if the computer was off at the time. On my machine I'm fixing it by making RunAtLoad true on the plist, but you may want to consider this as well for the official release?

bandgeekdante commented 6 years ago

My issue is that I generally turn off my Mac at night (so it'll be in dark mode) and when I turn it on in the morning it's already past sunrise and it just stays in dark mode. I'm using version 1.6 of darkmode and running macOS High Sierra. Other than that though I really appreciate the app!!

katernet commented 6 years ago

Thanks for the report @bandgeekdante

It seems scheduled launchd jobs indeed don't resume after shutdown - https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/ScheduledJobs.html

I have added a commit and released 1.7 to include RunAtLoad true in the launch agents. Thanks for the idea!

bandgeekdante commented 6 years ago

Thanks @katernet! I don't think you need RunAtLoad for both launch agents though since they both just call the darkmode bash script (for example on Mondays that would trigger the solar times to be updated twice I think, though I haven't tested that)

katernet commented 6 years ago

You're right, the script only needs to run once on load and having it in both will cause the script to run twice on login. I'll re-commit when I am back at my computer.