However, if I hibernate my laptop (Linux Mint 20.3) with PM running, then when it resumes the following day (or night, this is when the extension is supposed to switch between day and night or vice versa) the timer doesn't work even though from the log I can see that the callback function is being called.
I invoke the timer based on whether the extension's automatic setting is enabled in the color preferences dialog like so (shown below as well)
Code: Select all
if(branch.getBoolPref("enabled",false)) {
AutoPageColor.Common.printlog("Enabling timer.")
AutoPageColor.Common.timer.init(AutoPageColor.Common.timeObserver,
AutoPageColor.APC_TIMER_DELAY,AutoPageColor.Common.timer.TYPE_REPEATING_PRECISE_CAN_SKIP);
}
Code: Select all
timeObserver : {
observe : function(aSubject,aTopic,aData){
if(aTopic == 'timer-callback' && Common.prefBranch.getBoolPref("enabled",false)
&& Services.prefs.getIntPref("browser.display.prefers_color_scheme") > 0){
let sunrise = new Date(Common.prefBranch.getCharPref("sunrise"));
let sunset = new Date(Common.prefBranch.getCharPref("sunset"));
let current = new Date();
let now = current.getTime();
Common.printlog("Inside timer at "+Common.formatDate(current));
let title = Common.strBundle.GetStringFromName("notification.title");
if(Services.prefs.getIntPref("browser.display.prefers_color_scheme") == 1 &&
(now > sunset.getTime() || now < sunrise.getTime())){
Services.prefs.setIntPref("browser.display.prefers_color_scheme",2); //dark theme
Common.showAlert(true);
} else if(Services.prefs.getIntPref("browser.display.prefers_color_scheme") == 2 &&
(now > sunrise.getTime() && now < sunset.getTime())){
Services.prefs.setIntPref("browser.display.prefers_color_scheme",1); //light theme
Common.showAlert(false);
}
}
}
}
So I'm wondering if it's a generic OS level quirk with creating repeating timers since it applies to 2 totally different browsers.