Closed andreiborisov closed 6 years ago
For example
spoon.DarkMode:start()
print(hs.inspect.inspect(spoon.DarkMode:getSchedule()))
produces:
2018-11-04 19:40:36: { {
onAt = {
sunEvent = "sunset",
time = "16:50:07"
}
}, {
offAt = {
sunEvent = "sunrise",
time = "07:34:26"
}
} }
But when reloading config in Hammerspoon, it switches from already enabled dark theme to light one.
I've been fighting with a few different issues that might be the cause of this. I'm going to play around a bit now and see if I can figure out what's going on.
Which commit of the code are you on?
The latest one (as of now): https://github.com/malob/DarkMode.spoon/commit/9d113a5ac13fd924bdc1a26255ea040d19e5cb76
Cool, did updating to that commit fix the issue for you? There was a typo that was fixed in that commit that might have caused the issue.
No, the issue persists😔
It's also the same if I try to set time manually with spoon.DarkMode:setSchedule()
Alright, the issue is almost certainly in shouldDMBeOn(). I need to sit down once and for all and figure out what the logic should be there.
Something like this?
local function shouldDMBeOn(onTime, offTime, currentTime)
if onTime > offTime then
if currentTime >= onTime or currentTime < offTime then
return true
end
else
if currentTime >= onTime and currentTime < offTime then
return true
end
end
return false
end
I literally just wrote the same thing 😀 Is that working for you? I'm still testing it on my end.
Seems to be working when doing spoon.DarkMode:start()
, but it doesn't toggle on scheduled time. Although, it's probably different issue.
Hmmm, so I'm pretty confident that code is right now. I'm experiencing a separate issue where, it's not changing Dark Mode the next time it's supposed to. I've been playing around with times using setSchedule()
and I'm getting the following behavior.
Let's say it's 17:00, and Dark Mode is currently off on my computer.
If I run spoon.DarkMode:setSchedule("17:01", "17:04")
in the console, Dark Mode doesn't turn on at all.
If I run spoon.DarkMode:setSchedule("16:56", "17:04")
in the console, Dark Mode comes on right away (like it should), but it doesn't turn off at 17:04.
I've tested pretty carefully to make sure that the toggleTime
set in manageDMSchedule()
is working correctly. What seems to be going on, is that the timer isn't going off when it should to trigger the next change.
I'm trying to work out what's going on with that now.
I’ve opened separate issue for it: https://github.com/malob/DarkMode.spoon/issues/6
Issue should be resolved in commit 43e919b
spoon.DarkMode:start()
switches to light mode at night