kitty:daemon: Support optional instance group name

This commit is contained in:
2025-08-26 13:14:32 +02:00
parent a7e4c2c770
commit 07428c661d
2 changed files with 11 additions and 2 deletions

View File

@@ -2,6 +2,8 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 Julian Prein
#
# Usage: kitty-daemon [GROUP_NAME]
#
# Daemonize kitty by launching one hidden instance that new invocations can use
# to create new OS windows. This makes kitty startup a lot faster since all
# windows can now share a single CPU process and GPU sprite cache. Additionally
@@ -11,6 +13,10 @@
#
# kitty --single-instance
#
# You can pass an optional instance-group as first parameter. In that case use:
#
# kitty --single-instance --instance-group <NAME>
#
# NOTE: `--start-as hidden` needs kitty 0.42.0 or later.
TMP_DIR="${TMPDIR:-/tmp}/kitty.$USER"
@@ -18,7 +24,8 @@ mkdir -p "$TMP_DIR"
kitty \
--single-instance \
${1:+--instance-group "$1"} \
--start-as hidden \
--detach \
-o allow_remote_control=socket-only \
--listen-on unix:"$TMP_DIR/kitty.sock"
--listen-on unix:"$TMP_DIR/kitty${1:+-$1}.sock"

View File

@@ -2,10 +2,12 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 Julian Prein
#
# Usage: kitty-cwd [GROUP_NAME]
#
# Print the current working directory of the focused kitty window. Returns 4 if
# none exist or is focused.
socket_path="${TMPDIR:-/tmp}/kitty.$USER/kitty.sock"
socket_path="${TMPDIR:-/tmp}/kitty.$USER/kitty${1:+-$1}.sock"
# NOTE: the backticks are used for hacky line-continuation, taken from
# https://stackoverflow.com/a/7729087/2092762c9