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
This commit is contained in:
sankalp committed 2026-07-15 10:31:28 +05:45
1 parent e63a2c04a5
commit 9eb62d7ea3
7 files changed
+148 -55

No files matched your search

+15 -1
View File
@@ -11,7 +11,21 @@ CACHE_DIR = str(GLib.get_user_cache_dir()) + f"/{APP_NAME}"
CONFIG_DIR = os.path.expanduser(f"~/.config/{APP_NAME}") CONFIG_DIR = os.path.expanduser(f"~/.config/{APP_NAME}")
SYSTEM_CACHE_DIR = GLib.get_user_cache_dir() 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" WALLPAPER_THUMBS_PATH = f"{WALLPAPER_PATH}/.thumbnails"
WALLPAPERS_THUMBNAILS_SIZE = 200 WALLPAPERS_THUMBNAILS_SIZE = 200
WALLPAPERS_DIR_DEFAULT = get_relative_path("../assets/wallpapers_example/") WALLPAPERS_DIR_DEFAULT = get_relative_path("../assets/wallpapers_example/")
+5 -3
View File
@@ -1,5 +1,4 @@
DEFAULT = { DEFAULT = {
"wallpapers_dir": "~/Pictures/Wallpapers/",
"dock_enabled": True, "dock_enabled": True,
"dock_auto_hide": True, "dock_auto_hide": True,
"dock_always_occluded": False, "dock_always_occluded": False,
@@ -14,6 +13,8 @@ DEFAULT = {
"control_center": True, "control_center": True,
"search": True, "search": True,
"global_menu": True, "global_menu": True,
"global_menu_method": "hyprland",
"global_menu_cache_enabled": True,
"network": True, "network": True,
"battery": True, "battery": True,
"notification_center": True, "notification_center": True,
@@ -23,9 +24,10 @@ DEFAULT = {
"night_light_temperature": 4500, "night_light_temperature": 4500,
"custom_mods": True, "custom_mods": True,
"keyboard_layouts": ["us", "np"], "keyboard_layouts": ["us", "np"],
"window_switcher": True,
"switcher_live_preview": True, "switcher_live_preview": True,
"switcher_live_preview_delay_ms": 200, "switcher_live_preview_delay_ms": 200,
"osd": True,
"systray_ignore": ["blueman", "network"], "systray_ignore": ["blueman", "network"],
"wallpapers_dir": "~/Pictures/Wallpapers",
"osd": True,
"window_switcher": True,
} }
+12 -5
View File
@@ -222,9 +222,15 @@ def executable_gtk_class(executable: str | None) -> str | None:
cache = _load_cache() cache = _load_cache()
key = f"{path}" key = f"{path}"
cached = cache.get(key)
if cached and cached.get("mtime") == mtime: from services.config import get_config
return cached.get("class")
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) needed = _transitive_needed(path)
if GTK4_SONAME in needed: if GTK4_SONAME in needed:
@@ -234,6 +240,7 @@ def executable_gtk_class(executable: str | None) -> str | None:
else: else:
klass = None klass = None
cache[key] = {"mtime": mtime, "class": klass} if use_cache:
_save_cache(cache) cache[key] = {"mtime": mtime, "class": klass}
_save_cache(cache)
return klass return klass
+14 -5
View File
@@ -619,11 +619,20 @@ class GlobalMenuService(Service):
if target_pid <= 0: if target_pid <= 0:
return None return None
strategies = [ from services.config import get_config
self._find_registry,
self._find_registrar, method = get_config("global_menu_method", "hyprland")
self._find_fallback_scan,
] 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: for strategy in strategies:
result = strategy(wm_class, target_pid) result = strategy(wm_class, target_pid)
+8
View File
@@ -38,9 +38,17 @@ class OSD(Box):
self.revealer.set_reveal_child(True) self.revealer.set_reveal_child(True)
def show_audio_osd(self): 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")) self.show_container(self.containers.get("audio"))
def show_brightness_osd(self): 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")) self.show_container(self.containers.get("brightness"))
+92 -41
View File
@@ -224,9 +224,8 @@ class SettingsPage(ScrolledWindow):
h_expand=True, h_expand=True,
v_expand=True, v_expand=True,
propagate_width=True, propagate_width=True,
propagate_height=True, propagate_height=False,
min_content_width=600, min_content_width=600,
min_content_height=500,
**kwargs, **kwargs,
) )
self.add(container) self.add(container)
@@ -335,11 +334,6 @@ class SettingsWindow(Gtk.Window):
return SettingsPage( return SettingsPage(
"General Settings", "General Settings",
[ [
SettingsRow(
"Wallpapers Directory",
SettingsEntry("wallpapers_dir"),
"Path to your wallpaper collection",
),
SettingsRow( SettingsRow(
"Weather Location", "Weather Location",
SettingsEntry("weather_location"), SettingsEntry("weather_location"),
@@ -350,25 +344,25 @@ class SettingsWindow(Gtk.Window):
SettingsList("keyboard_layouts"), SettingsList("keyboard_layouts"),
"Manage active keyboard input languages", "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( SettingsRow(
"Hide Special Workspace", "Hide Special Workspace",
SettingsSwitch("hide_special_workspace"), SettingsSwitch("hide_special_workspace"),
"Don't show special workspace in indicators", "Don't show special workspace in indicators",
), ),
SettingsRow( SettingsRow(
"OSD", "Night Light Temperature",
SettingsSwitch("osd"), SettingsEntry("night_light_temperature"),
"On-screen display for volume/brightness", "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): def _create_panel_page(self):
# panel visibility settings rows = [
rows = [] SettingsRow(
panel_settings = [ "Global Menu",
("iMac Button", "imac_button"), SettingsSwitch("global_menu"),
("Global Menu", "global_menu"), "Show application menu in the panel",
("Systray", "systray"), ),
("Control Center", "control_center"), SettingsRow(
("Search", "search"), "Menu Method",
("Network", "network"), SettingsEntry("global_menu_method"),
("Battery", "battery"), "Detection method: auto, hyprland, or dbus",
("Bluetooth", "bluetooth"), ),
("Date & Time", "date_time"), SettingsRow(
("Workspace Indicator", "workspace_indicator"), "Menu Cache",
("Notification Center", "notification_center"), SettingsSwitch("global_menu_cache_enabled"),
] "Cache GTK class detection results",
for label, key in panel_settings: ),
rows.append(SettingsRow(label, SettingsSwitch(key))) SettingsRow(
"iMac Button",
rows.append( 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( SettingsRow(
"Systray Ignore", "Systray Ignore",
SettingsList("systray_ignore"), SettingsList("systray_ignore"),
"Icons to hide from the system tray", "Icons to hide from the system tray",
) ),
) ]
return SettingsPage("Panel Settings", rows) return SettingsPage("Panel Settings", rows)
+2
View File
@@ -133,6 +133,8 @@ class ApplicationSwitcher(Window):
self._rebuild() self._rebuild()
def show_switcher(self) -> None: def show_switcher(self) -> None:
if not config().get("window_switcher", True):
return
self._rebuild() self._rebuild()
if not self.windows: if not self.windows:
return return