skhzhang / time-based-themes

Automatically change Firefox's theme based on the time
MIT License
121 stars 13 forks source link

Fix delay in alarms after OS sleep/hibernation #6

Closed abaco closed 5 years ago

abaco commented 5 years ago

Any sleep/hibernation currently messes up the schedule. If my laptop goes into sleep for two hours, the next theme change will be delayed by two hours. Since I usually keep Firefox running for days and just close the laptop when I don't use it, with this extension I get the theme changing at basically random times.

This fix just reschedules the alarms at every windows.onFocusChanged event. It's not completely fail proof, as waking up the computer doesn't by itself trigger a onFocusChanged event, so I'm not sure this is the right solution. The older versions of the extension, which checked the time every N minutes, were good for me. With this approach the timing is more accurate, but I would be fine with any fix.