From 6442161f404fd2d3d4088116abd6712a6c7ccf75 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Wed, 15 Jul 2026 19:37:02 +0545 Subject: [PATCH] refactor(src/window/globalmenu): simplify caching logic and remove dynamic menu method selection --- src/window/globalmenu/detection.py | 16 +++++----------- src/window/globalmenu/service.py | 19 +++++-------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/window/globalmenu/detection.py b/src/window/globalmenu/detection.py index 1a9fb04..7399f5f 100644 --- a/src/window/globalmenu/detection.py +++ b/src/window/globalmenu/detection.py @@ -223,14 +223,9 @@ def executable_gtk_class(executable: str | None) -> str | None: cache = _load_cache() key = f"{path}" - from services.config import get_config - - use_cache = get_config("global_menu_cache_enabled", True) - - if use_cache: - cached = cache.get(key) - if cached and cached.get("mtime") == mtime: - return cached.get("class") + cached = cache.get(key) + if cached and cached.get("mtime") == mtime: + return cached.get("class") needed = _transitive_needed(path) if GTK4_SONAME in needed: @@ -240,7 +235,6 @@ def executable_gtk_class(executable: str | None) -> str | None: else: klass = None - if use_cache: - cache[key] = {"mtime": mtime, "class": klass} - _save_cache(cache) + cache[key] = {"mtime": mtime, "class": klass} + _save_cache(cache) return klass diff --git a/src/window/globalmenu/service.py b/src/window/globalmenu/service.py index 252950f..b0b6b7d 100644 --- a/src/window/globalmenu/service.py +++ b/src/window/globalmenu/service.py @@ -619,20 +619,11 @@ class GlobalMenuService(Service): if target_pid <= 0: return None - from services.config import get_config - - method = get_config("global_menu_method", "hyprland") - - strategies = [] - if method in ("hyprland", "auto"): - strategies.extend( - [ - self._find_registry, - self._find_registrar, - ] - ) - if method in ("dbus", "auto"): - strategies.append(self._find_fallback_scan) + strategies = [ + self._find_registry, + self._find_registrar, + self._find_fallback_scan, + ] for strategy in strategies: result = strategy(wm_class, target_pid)