From 3df0194f6ed0de99081c93ac6c54b3a700211b4d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Mar 2022 22:18:35 +0530 Subject: [PATCH] Use a well known runtime dir if XDG_RUNTIME_DIR not available --- kitty/constants.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kitty/constants.py b/kitty/constants.py index 0e9783b02..9d85984de 100644 --- a/kitty/constants.py +++ b/kitty/constants.py @@ -146,7 +146,9 @@ def runtime_dir() -> str: elif 'XDG_RUNTIME_DIR' in os.environ: candidate = os.path.abspath(os.environ['XDG_RUNTIME_DIR']) else: - candidate = os.environ.get('XDG_RUNTIME_DIR', os.path.join(cache_dir(), 'run')) + candidate = f'/run/user/{os.geteuid()}' + if not os.path.isdir(candidate) or not os.access(candidate, os.X_OK | os.W_OK | os.R_OK): + candidate = os.path.join(cache_dir(), 'run') os.makedirs(candidate, exist_ok=True) os.chmod(candidate, 0o700) return candidate