From 48c84099ba9ecb78ecf8f3fa19a849d9e51eb4a9 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 28 Apr 2024 22:15:25 +0100 Subject: [PATCH] prefer xdg env --- src/Compositor.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 0f3ad981..358dad1a 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -63,14 +63,15 @@ void handleUserSignal(int sig) { CCompositor::CCompositor() { m_iHyprlandPID = getpid(); - const auto PWUID = getpwuid(getuid()); - if (!PWUID) { - std::cout << "Bailing out, getpwuid(getuid()) failed. Are you running as a proper user?\n"; + m_szHyprTempDataRoot = std::string{getenv("XDG_RUNTIME_DIR")} + "/hypr"; + + if (m_szHyprTempDataRoot.starts_with("/hypr")) { + std::cout << "Bailing out, XDG_RUNTIME_DIR is invalid\n"; throw std::runtime_error("CCompositor() failed"); } - const std::string USERID = std::to_string(PWUID->pw_uid); - m_szHyprTempDataRoot = "/run/user/" + USERID + "/hypr"; + if (!m_szHyprTempDataRoot.starts_with("/run/user")) + std::cout << "[!!WARNING!!] XDG_RUNTIME_DIR looks non-standard. Proceeding anyways...\n"; std::random_device dev; std::mt19937 engine(dev());