prefer xdg env

This commit is contained in:
Vaxry 2024-04-28 22:15:25 +01:00
parent 80cff19117
commit 48c84099ba
1 changed files with 6 additions and 5 deletions

View File

@ -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());