Merge pull request #10605 from omacom/fix/kitty-system-defaults

Move Kitty defaults to the system config and restrict remote control

(cherry picked from commit f04366de79)
(cherry picked from commit 6dfbfa146b91bf310f2ff7147953afddef73de9a)
This commit is contained in:
Ryan Hughes committed 2026-09-07 20:57:03 -04:00
1 parent 7a35a8ee9b
commit 6a72d4236b
9 files changed
+358 -34

No files matched your search

@@ -0,0 +1,58 @@
import os
from pathlib import Path
from tempfile import TemporaryDirectory
from kitty.config import load_config
from kitty.options.utils import parse_map
root = Path(os.environ['ROOT'])
system = root / 'etc/xdg/kitty/kitty.conf'
template = root / 'config/kitty/kitty.conf'
legacy = root / 'test/shell.d/fixtures/kitty/legacy.conf'
active_lines = [line for line in template.read_text().splitlines() if line and not line.startswith('#')]
assert active_lines == ['include ~/.local/state/omarchy/current/theme/kitty.conf']
with TemporaryDirectory() as tmp:
user = Path(tmp) / 'kitty.conf'
# Use a local theme to avoid depending on the developer's generated state.
theme = Path(tmp) / 'theme.conf'
theme.write_text('background #123456\n')
themed = f'include {theme}\n'
user.write_text(themed)
errors = []
opts = load_config(str(system), str(user), accumulate_bad_lines=errors)
assert not errors, errors
assert opts.allow_remote_control == 'socket-only'
assert opts.listen_on == 'unix:${XDG_RUNTIME_DIR}/omarchy-kitty-{kitty_pid}'
old = Path(tmp) / 'legacy.conf'
old.write_text(legacy.read_text().replace(active_lines[0], themed.strip()))
before = load_config(str(old), accumulate_bad_lines=errors)
# Moving defaults must preserve appearance and behavior except remote control.
for key in ('font_family', 'bold_italic_font', 'font_size', 'window_padding_width',
'hide_window_decorations', 'confirm_os_window_close', 'cursor_shape',
'cursor_blink_interval', 'shell_integration', 'enable_audio_bell',
'tab_bar_edge', 'tab_bar_style', 'tab_powerline_style',
'tab_title_template', 'background'):
assert getattr(opts, key) == getattr(before, key), key
def binding(options, shortcut):
trigger = next(parse_map(shortcut)).trigger
return [entry.definition for entry in options.keyboard_modes[''].keymap.get(trigger, [])]
for shortcut in ('ctrl+insert', 'shift+insert', 'shift+enter', 'alt+shift+enter'):
assert binding(opts, shortcut) == binding(before, shortcut), shortcut
user.write_text(themed + 'font_size 15\nmap ctrl+insert\nmap shift+insert copy_to_clipboard\n')
opts = load_config(str(system), str(user), accumulate_bad_lines=errors)
assert opts.font_size == 15
assert not any(binding(opts, 'ctrl+insert'))
assert binding(opts, 'shift+insert')[-1] == 'copy_to_clipboard'
user.write_text(themed + 'clear_all_shortcuts yes\nmap f1 new_window\n')
opts = load_config(str(system), str(user), accumulate_bad_lines=errors)
assert len(opts.keyboard_modes[''].keymap) == 1
assert binding(opts, 'f1') == ['new_window']
assert not errors, errors
print('ok - Kitty loads defaults and theme, preserves appearance, and supports user overrides and unmapping')
+35
View File
@@ -0,0 +1,35 @@
include ~/.local/state/omarchy/current/theme/kitty.conf
# Font
font_family JetBrainsMono Nerd Font
bold_italic_font auto
font_size 9.0
# Window
window_padding_width 14
hide_window_decorations yes
confirm_os_window_close 0
# Keybindings
map ctrl+insert copy_to_clipboard
map shift+insert paste_from_clipboard
# Send Shift+Enter as CSI-u so TUIs can distinguish it from Enter.
map shift+enter send_text all \e[13;2u
# Kitty legacy encoding sends Alt+Shift+Enter the same as Alt+Enter; send CSI-u so tmux can match M-S-Enter.
map alt+shift+enter send_text all \e[13;4u
# Allow remote access
allow_remote_control yes
listen_on unix:${XDG_RUNTIME_DIR}/omarchy-kitty-{kitty_pid}
# Aesthetics
cursor_shape block
cursor_blink_interval 0
shell_integration no-cursor
enable_audio_bell no
# Minimal Tab bar styling
tab_bar_edge bottom
tab_bar_style powerline
tab_powerline_style slanted
tab_title_template {title}{' :{}:'.format(num_windows) if num_windows > 1 else ''}