restore: move to runtime dir and check his

fixes #346
This commit is contained in:
Vaxry 2024-05-23 12:58:54 +02:00
parent ba4b08e5f5
commit 972c1c27e6
3 changed files with 22 additions and 17 deletions

View file

@ -1083,10 +1083,16 @@ void CHyprlock::attemptRestoreOnDeath() {
if (m_bTerminate) if (m_bTerminate)
return; return;
const auto XDG_RUNTIME_DIR = getenv("XDG_RUNTIME_DIR");
const auto HIS = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!XDG_RUNTIME_DIR || !HIS)
return;
// dirty hack // dirty hack
uint64_t timeNowMs = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t({0})).count(); uint64_t timeNowMs = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t({0})).count();
constexpr const char* LASTRESTARTPATH = "/tmp/hypr/.hyprlockrestart"; const auto LASTRESTARTPATH = std::string{XDG_RUNTIME_DIR} + "/.hyprlockrestart";
if (std::filesystem::exists(LASTRESTARTPATH)) { if (std::filesystem::exists(LASTRESTARTPATH)) {
std::ifstream ifs(LASTRESTARTPATH); std::ifstream ifs(LASTRESTARTPATH);

View file

@ -52,7 +52,6 @@ cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::filesystem::path& path)
return nullptr; return nullptr;
} }
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
config.output.colorspace = MODE_bgrA; config.output.colorspace = MODE_bgrA;
#else #else
@ -81,5 +80,4 @@ cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::filesystem::path& path)
WebPFreeDecBuffer(&config.output); WebPFreeDecBuffer(&config.output);
return cairoSurface; return cairoSurface;
} }

View file

@ -204,7 +204,8 @@ CRenderer::SRenderFeedback CRenderer::renderLock(const CSessionLockSurface& surf
bga = 1.0; bga = 1.0;
if (g_pHyprlock->m_bFadeStarted && !**PNOFADEOUT) { if (g_pHyprlock->m_bFadeStarted && !**PNOFADEOUT) {
bga = std::clamp(std::chrono::duration_cast<std::chrono::microseconds>(g_pHyprlock->m_tFadeEnds - std::chrono::system_clock::now()).count() / 500000.0 - 0.02, 0.0, 1.0); bga =
std::clamp(std::chrono::duration_cast<std::chrono::microseconds>(g_pHyprlock->m_tFadeEnds - std::chrono::system_clock::now()).count() / 500000.0 - 0.02, 0.0, 1.0);
// - 0.02 so that the fade ends a little earlier than the final second // - 0.02 so that the fade ends a little earlier than the final second
} }
// render widgets // render widgets