Skip to content

Commit 7207170

Browse files
authored
core: fix scheduling after suspend (#59)
1 parent fa2f7dd commit 7207170

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/Hyprsunset.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,26 @@ void CHyprsunset::schedule() {
344344

345345
if (now >= time)
346346
time += std::chrono::days(1);
347-
347+
348+
while (time >= std::chrono::zoned_time(std::chrono::current_zone(), std::chrono::system_clock::now()).get_local_time() + std::chrono::minutes(1))
349+
std::this_thread::sleep_for(std::chrono::minutes(1));
350+
348351
auto system_time = std::chrono::zoned_time{std::chrono::current_zone(), time}.get_sys_time();
349352

350353
std::this_thread::sleep_until(system_time);
351354

355+
int newcurrent = currentProfile();
356+
if (newcurrent == -1)
357+
break;
358+
359+
SSunsetProfile newProfile = profiles[newcurrent];
360+
352361
std::lock_guard<std::mutex> lg(m_sEventLoopInternals.loopRequestMutex);
353-
KELVIN = nextProfile.temperature;
354-
GAMMA = nextProfile.gamma;
355-
identity = nextProfile.identity;
362+
KELVIN = newProfile.temperature;
363+
GAMMA = newProfile.gamma;
364+
identity = newProfile.identity;
356365

357-
Debug::log(NONE, "┣ Switched to new profile from: {}:{}", nextProfile.time.hour.count(), nextProfile.time.minute.count());
366+
Debug::log(NONE, "┣ Switched to new profile from: {}:{}", newProfile.time.hour.count(), newProfile.time.minute.count());
358367

359368
m_sEventLoopInternals.shouldProcess = true;
360369
m_sEventLoopInternals.isScheduled = true;

0 commit comments

Comments
 (0)