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.
This commit is contained in:
Kovid Goyal 2022-03-10 20:07:23 +05:30
parent 719339e116
commit 76a536ece0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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: