From 76a536ece04d3da9e5867f401bc51c70669f2ffa Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Mar 2022 20:07:23 +0530 Subject: [PATCH] On macOS always use the cache dir a runtime dir Also make the constant parts of the socket name shorter as there is a 104 bytes limit on it in macOS SSH. --- kitty/constants.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kitty/constants.py b/kitty/constants.py index b68c6e068..0e9783b02 100644 --- a/kitty/constants.py +++ b/kitty/constants.py @@ -141,10 +141,12 @@ def cache_dir() -> str: def runtime_dir() -> str: if 'KITTY_RUNTIME_DIRECTORY' in os.environ: candidate = os.path.abspath(os.environ['KITTY_RUNTIME_DIRECTORY']) + elif is_macos: + candidate = os.path.join(cache_dir(), 'run') elif 'XDG_RUNTIME_DIR' in os.environ: candidate = os.path.abspath(os.environ['XDG_RUNTIME_DIR']) else: - candidate = os.path.join(cache_dir(), 'run') + candidate = os.environ.get('XDG_RUNTIME_DIR', os.path.join(cache_dir(), 'run')) os.makedirs(candidate, exist_ok=True) os.chmod(candidate, 0o700) return candidate @@ -167,7 +169,9 @@ except KeyError: with suppress(Exception): print('Failed to read login shell via getpwuid() for current user, falling back to /bin/sh', file=sys.stderr) shell_path = '/bin/sh' -ssh_control_master_template = 'ssh-kitten-{kitty_pid}-master-{ssh_placeholder}' +# Keep this short as it is limited to 103 bytes on macOS +# https://github.com/ansible/ansible/issues/11536#issuecomment-153030743 +ssh_control_master_template = 'kssh-{kitty_pid}-{ssh_placeholder}' def glfw_path(module: str) -> str: