From 963ca393038462b6125a5e7b434667cc87e88e74 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 1 Aug 2026 20:46:33 +0545 Subject: [PATCH] perf: lazy-load settings window to cut startup memory --- src/main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index d4d5e02..b5c62e2 100644 --- a/src/main.py +++ b/src/main.py @@ -86,6 +86,13 @@ def setup_css(app): app.connect("shutdown", cleanup_css_monitors) +class _LazySettingsWindow: + """Forward attribute access to the settings window, creating it on first use.""" + + def __getattr__(self, name): + return getattr(get_settings_window(), name) + + def main(): set_process_name(APP_NAME) load_config() @@ -109,7 +116,6 @@ def main(): dock = Dock() osd = OSDWindow() screencapture = ScreenCaptureWindow() - settings = get_settings_window() # Register windows with the application for w in [ @@ -139,7 +145,7 @@ def main(): __main__.screencapture = screencapture __main__.lock_screen = LockScreenWrapper() __main__.switch_keyboard_layout = KeyboardLayout.switch_keyboard_layout - __main__.settings = settings + __main__.settings = _LazySettingsWindow() __main__.desktop_widgets = DesktopWidgetService.get_instance() app.run()