From 9eb62d7ea3632bf41761d1c0f347ab006844a890 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Wed, 15 Jul 2026 10:31:28 +0545 Subject: [PATCH] feat(config): wire up wallpapers_dir, osd, window_switcher, global_menu settings - wallpapers_dir: read from config, fallback ~/Pictures/Wallpapers - osd: skip show_audio_osd/show_brightness_osd when disabled - window_switcher: skip show_switcher when disabled - global_menu_cache_enabled: bypass GTK class cache when false - global_menu_method: control discovery strategies (auto/hyprland/dbus) All keys added to constants.py defaults, settings UI, and config.toml --- src/shared/data.py | 16 +++- src/utils/constants.py | 8 +- src/window/globalmenu/detection.py | 17 ++-- src/window/globalmenu/service.py | 19 +++-- src/window/osd/main.py | 8 ++ src/window/settings/main.py | 133 ++++++++++++++++++++--------- src/window/switcher/main.py | 2 + 7 files changed, 148 insertions(+), 55 deletions(-) diff --git a/src/shared/data.py b/src/shared/data.py index 61312ea..b215483 100644 --- a/src/shared/data.py +++ b/src/shared/data.py @@ -11,7 +11,21 @@ CACHE_DIR = str(GLib.get_user_cache_dir()) + f"/{APP_NAME}" CONFIG_DIR = os.path.expanduser(f"~/.config/{APP_NAME}") SYSTEM_CACHE_DIR = GLib.get_user_cache_dir() -WALLPAPER_PATH = f"{HOME_DIR}/Pictures/Wallpapers" + + +def _get_wallpaper_path() -> str: + try: + from services.config import get_config + + custom = get_config("wallpapers_dir") + if custom: + return os.path.expanduser(str(custom)) + except Exception: + pass + return f"{HOME_DIR}/Pictures/Wallpapers" + + +WALLPAPER_PATH = _get_wallpaper_path() WALLPAPER_THUMBS_PATH = f"{WALLPAPER_PATH}/.thumbnails" WALLPAPERS_THUMBNAILS_SIZE = 200 WALLPAPERS_DIR_DEFAULT = get_relative_path("../assets/wallpapers_example/") diff --git a/src/utils/constants.py b/src/utils/constants.py index d2a48c0..918fd10 100644 --- a/src/utils/constants.py +++ b/src/utils/constants.py @@ -1,5 +1,4 @@ DEFAULT = { - "wallpapers_dir": "~/Pictures/Wallpapers/", "dock_enabled": True, "dock_auto_hide": True, "dock_always_occluded": False, @@ -14,6 +13,8 @@ DEFAULT = { "control_center": True, "search": True, "global_menu": True, + "global_menu_method": "hyprland", + "global_menu_cache_enabled": True, "network": True, "battery": True, "notification_center": True, @@ -23,9 +24,10 @@ DEFAULT = { "night_light_temperature": 4500, "custom_mods": True, "keyboard_layouts": ["us", "np"], - "window_switcher": True, "switcher_live_preview": True, "switcher_live_preview_delay_ms": 200, - "osd": True, "systray_ignore": ["blueman", "network"], + "wallpapers_dir": "~/Pictures/Wallpapers", + "osd": True, + "window_switcher": True, } diff --git a/src/window/globalmenu/detection.py b/src/window/globalmenu/detection.py index f608771..1a9fb04 100644 --- a/src/window/globalmenu/detection.py +++ b/src/window/globalmenu/detection.py @@ -222,9 +222,15 @@ def executable_gtk_class(executable: str | None) -> str | None: cache = _load_cache() key = f"{path}" - cached = cache.get(key) - if cached and cached.get("mtime") == mtime: - return cached.get("class") + + 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") needed = _transitive_needed(path) if GTK4_SONAME in needed: @@ -234,6 +240,7 @@ def executable_gtk_class(executable: str | None) -> str | None: else: klass = None - cache[key] = {"mtime": mtime, "class": klass} - _save_cache(cache) + if use_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 b0b6b7d..252950f 100644 --- a/src/window/globalmenu/service.py +++ b/src/window/globalmenu/service.py @@ -619,11 +619,20 @@ class GlobalMenuService(Service): if target_pid <= 0: return None - strategies = [ - self._find_registry, - self._find_registrar, - self._find_fallback_scan, - ] + 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) for strategy in strategies: result = strategy(wm_class, target_pid) diff --git a/src/window/osd/main.py b/src/window/osd/main.py index 5d1e4b7..6d3930d 100644 --- a/src/window/osd/main.py +++ b/src/window/osd/main.py @@ -38,9 +38,17 @@ class OSD(Box): self.revealer.set_reveal_child(True) def show_audio_osd(self): + from services.config import get_config + + if not get_config("osd", True): + return self.show_container(self.containers.get("audio")) def show_brightness_osd(self): + from services.config import get_config + + if not get_config("osd", True): + return self.show_container(self.containers.get("brightness")) diff --git a/src/window/settings/main.py b/src/window/settings/main.py index 55a0cb5..88d2315 100644 --- a/src/window/settings/main.py +++ b/src/window/settings/main.py @@ -224,9 +224,8 @@ class SettingsPage(ScrolledWindow): h_expand=True, v_expand=True, propagate_width=True, - propagate_height=True, + propagate_height=False, min_content_width=600, - min_content_height=500, **kwargs, ) self.add(container) @@ -335,11 +334,6 @@ class SettingsWindow(Gtk.Window): return SettingsPage( "General Settings", [ - SettingsRow( - "Wallpapers Directory", - SettingsEntry("wallpapers_dir"), - "Path to your wallpaper collection", - ), SettingsRow( "Weather Location", SettingsEntry("weather_location"), @@ -350,25 +344,25 @@ class SettingsWindow(Gtk.Window): SettingsList("keyboard_layouts"), "Manage active keyboard input languages", ), - SettingsRow( - "Window Switcher", - SettingsSwitch("window_switcher"), - "Enable the Alt-Tab window switcher", - ), - SettingsRow( - "Items Per Row", - SettingsEntry("window_switcher_items_per_row"), - "Maximum items in window switcher row", - ), SettingsRow( "Hide Special Workspace", SettingsSwitch("hide_special_workspace"), "Don't show special workspace in indicators", ), SettingsRow( - "OSD", - SettingsSwitch("osd"), - "On-screen display for volume/brightness", + "Night Light Temperature", + SettingsEntry("night_light_temperature"), + "Color temperature in Kelvin (e.g. 4500)", + ), + SettingsRow( + "Live Preview", + SettingsSwitch("switcher_live_preview"), + "Show live window previews in switcher", + ), + SettingsRow( + "Preview Delay (ms)", + SettingsEntry("switcher_live_preview_delay_ms"), + "Delay before live preview appears", ), ], ) @@ -406,31 +400,88 @@ class SettingsWindow(Gtk.Window): ) def _create_panel_page(self): - # panel visibility settings - rows = [] - panel_settings = [ - ("iMac Button", "imac_button"), - ("Global Menu", "global_menu"), - ("Systray", "systray"), - ("Control Center", "control_center"), - ("Search", "search"), - ("Network", "network"), - ("Battery", "battery"), - ("Bluetooth", "bluetooth"), - ("Date & Time", "date_time"), - ("Workspace Indicator", "workspace_indicator"), - ("Notification Center", "notification_center"), - ] - for label, key in panel_settings: - rows.append(SettingsRow(label, SettingsSwitch(key))) - - rows.append( + rows = [ + SettingsRow( + "Global Menu", + SettingsSwitch("global_menu"), + "Show application menu in the panel", + ), + SettingsRow( + "Menu Method", + SettingsEntry("global_menu_method"), + "Detection method: auto, hyprland, or dbus", + ), + SettingsRow( + "Menu Cache", + SettingsSwitch("global_menu_cache_enabled"), + "Cache GTK class detection results", + ), + SettingsRow( + "iMac Button", + SettingsSwitch("imac_button"), + ), + SettingsRow( + "Systray", + SettingsSwitch("systray"), + ), + SettingsRow( + "Control Center", + SettingsSwitch("control_center"), + ), + SettingsRow( + "Search", + SettingsSwitch("search"), + ), + SettingsRow( + "Network", + SettingsSwitch("network"), + ), + SettingsRow( + "Battery", + SettingsSwitch("battery"), + ), + SettingsRow( + "Bluetooth", + SettingsSwitch("bluetooth"), + ), + SettingsRow( + "Date & Time", + SettingsSwitch("date_time"), + ), + SettingsRow( + "Workspace Indicator", + SettingsSwitch("workspace_indicator"), + ), + SettingsRow( + "Notification Center", + SettingsSwitch("notification_center"), + ), + SettingsRow( + "Custom Mods", + SettingsSwitch("custom_mods"), + "Enable custom Hyprland mods in panel", + ), + SettingsRow( + "Window Switcher", + SettingsSwitch("window_switcher"), + "Enable Alt+Tab window switcher", + ), + SettingsRow( + "OSD", + SettingsSwitch("osd"), + "Enable on-screen display for volume/brightness", + ), + SettingsRow( + "Wallpapers Directory", + SettingsEntry("wallpapers_dir"), + "Path to wallpapers folder", + ), SettingsRow( "Systray Ignore", SettingsList("systray_ignore"), "Icons to hide from the system tray", - ) - ) + ), + ] return SettingsPage("Panel Settings", rows) diff --git a/src/window/switcher/main.py b/src/window/switcher/main.py index 1f4249b..788828b 100644 --- a/src/window/switcher/main.py +++ b/src/window/switcher/main.py @@ -133,6 +133,8 @@ class ApplicationSwitcher(Window): self._rebuild() def show_switcher(self) -> None: + if not config().get("window_switcher", True): + return self._rebuild() if not self.windows: return