mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 15:35:03 +02:00
Implement auto reload of config
This commit is contained in:
@@ -1390,10 +1390,15 @@ class Boss:
|
||||
else:
|
||||
self.startup_first_child(first_os_window_id, startup_sessions=startup_sessions)
|
||||
|
||||
if get_options().update_check_interval > 0 and not self.update_check_started and getattr(sys, 'frozen', False):
|
||||
|
||||
if (opts := get_options()).update_check_interval > 0 and not self.update_check_started and getattr(sys, 'frozen', False):
|
||||
from .update_check import run_update_check
|
||||
run_update_check(get_options().update_check_interval * 60 * 60)
|
||||
self.update_check_started = True
|
||||
if opts.auto_reload_config >= 0 and not hasattr(self, 'config_reload_watcher_process'):
|
||||
self.config_reload_watcher_process = subprocess.Popen(
|
||||
[kitten_exe(), '__watch_conf__', str(os.getpid()), str(int(opts.auto_reload_config * 1000))] +
|
||||
list(opts.all_config_paths), stdin=subprocess.PIPE)
|
||||
|
||||
def handle_window_title_bar_mouse(self, os_window_id: int, window_id: int, x: float, y: float, button: int, modifiers: int, action: int) -> None:
|
||||
if tm := self.os_window_map.get(os_window_id):
|
||||
|
||||
@@ -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='''
|
||||
|
||||
3
kitty/options/parse.py
generated
3
kitty/options/parse.py
generated
@@ -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)
|
||||
|
||||
|
||||
2
kitty/options/types.py
generated
2
kitty/options/types.py
generated
@@ -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, ...] = ()
|
||||
|
||||
Reference in New Issue
Block a user