Implement auto reload of config

This commit is contained in:
Kovid Goyal
2026-04-16 14:39:51 +05:30
parent efbfbb49f9
commit e9f3844f64
8 changed files with 29 additions and 4 deletions

View File

@@ -2393,6 +2393,15 @@ reloading the config is not supported.
'''
)
opt('auto_reload_config', '0.1', option_type='float', long_text='''
Automatically reload configuration files when they are changed. The setting
is the number of seconds to wait before reloading the config files. This allows
multiple changes to be debounced. Use a negative value to disable automatic reload.
You can manually reload with :sc:`reload_config_file`. Note that automatic
reload works only if the :file:`kitty.conf` already exists when kitty is started.
Changes to this setting by reloading configuration are ignored.
''')
opt('startup_session', 'none',
option_type='config_or_absolute_path',
long_text='''

View File

@@ -71,6 +71,9 @@ class Parser:
choices_for_allow_remote_control = frozenset(('password', 'socket-only', 'socket', 'no', 'n', 'false', 'yes', 'y', 'true'))
def auto_reload_config(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['auto_reload_config'] = float(val)
def background(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['background'] = to_color(val)

View File

@@ -53,6 +53,7 @@ option_names = (
'allow_cloning',
'allow_hyperlinks',
'allow_remote_control',
'auto_reload_config',
'background',
'background_blur',
'background_image',
@@ -527,6 +528,7 @@ class Options:
allow_cloning: choices_for_allow_cloning = 'ask'
allow_hyperlinks: int = 1
allow_remote_control: choices_for_allow_remote_control = 'no'
auto_reload_config: float = 0.1
background: Color = Color(0, 0, 0)
background_blur: int = 0
background_image: tuple[str, ...] = ()