refactor(config): reorganize config.toml into sections
- Move all settings into [general], [dock], [panel], [switcher], [notification] - Remove [desktop_widgets] section, move items to panel/general - Add dot notation support to config service for nested keys - Update all config references across codebase
This commit is contained in:
17 files changed
+204
-148
No files matched your search
+1
-1
@@ -45,7 +45,7 @@ def setup_logger():
|
|||||||
]:
|
]:
|
||||||
logger.disable(log)
|
logger.disable(log)
|
||||||
|
|
||||||
_debug = config().get("debug", False)
|
_debug = config().get("general.debug", False)
|
||||||
if not _debug:
|
if not _debug:
|
||||||
logger.disable("modus_plugin_builtin_emoji")
|
logger.disable("modus_plugin_builtin_emoji")
|
||||||
else:
|
else:
|
||||||
|
|||||||
+34
-4
@@ -47,17 +47,47 @@ class ConfigService:
|
|||||||
self._initialized = True
|
self._initialized = True
|
||||||
|
|
||||||
def get(self, key: str, default: Any = None) -> Any:
|
def get(self, key: str, default: Any = None) -> Any:
|
||||||
return self._config.get(key, default)
|
"""Get a config value. Supports dot notation for nested keys (e.g. 'dock.enabled')."""
|
||||||
|
parts = key.split(".")
|
||||||
|
current = self._config
|
||||||
|
for part in parts:
|
||||||
|
if isinstance(current, dict):
|
||||||
|
current = current.get(part)
|
||||||
|
if current is None:
|
||||||
|
return default
|
||||||
|
else:
|
||||||
|
return default
|
||||||
|
return current
|
||||||
|
|
||||||
def get_all(self) -> Dict[str, Any]:
|
def get_all(self) -> Dict[str, Any]:
|
||||||
return self._config.copy()
|
return self._config.copy()
|
||||||
|
|
||||||
def has_changed(self, key: str, old_config: Dict[str, Any]) -> bool:
|
def has_changed(self, key: str, old_config: Dict[str, Any]) -> bool:
|
||||||
return self._config.get(key) != old_config.get(key)
|
"""Check if a config value changed. Supports dot notation for nested keys."""
|
||||||
|
|
||||||
|
def _get_nested(d, k):
|
||||||
|
parts = k.split(".")
|
||||||
|
current = d
|
||||||
|
for part in parts:
|
||||||
|
if isinstance(current, dict):
|
||||||
|
current = current.get(part)
|
||||||
|
if current is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
return current
|
||||||
|
|
||||||
|
return _get_nested(self._config, key) != _get_nested(old_config, key)
|
||||||
|
|
||||||
def set(self, key: str, value: Any) -> None:
|
def set(self, key: str, value: Any) -> None:
|
||||||
"""Set a config value (local state only)."""
|
"""Set a config value (local state only). Supports dot notation for nested keys."""
|
||||||
self._config[key] = value
|
parts = key.split(".")
|
||||||
|
current = self._config
|
||||||
|
for part in parts[:-1]:
|
||||||
|
if part not in current:
|
||||||
|
current[part] = {}
|
||||||
|
current = current[part]
|
||||||
|
current[parts[-1]] = value
|
||||||
|
|
||||||
def save(self) -> None:
|
def save(self) -> None:
|
||||||
"""Persist current in-memory config to disk."""
|
"""Persist current in-memory config to disk."""
|
||||||
|
|||||||
@@ -238,9 +238,11 @@ class CachedNotifications(Notifications):
|
|||||||
on_config_change(self._on_config_changed)
|
on_config_change(self._on_config_changed)
|
||||||
|
|
||||||
def _on_config_changed(self, new_config, old_config):
|
def _on_config_changed(self, new_config, old_config):
|
||||||
|
new_notif = new_config.get("notification", {})
|
||||||
|
|
||||||
# If ignored apps changed, remove them from history
|
# If ignored apps changed, remove them from history
|
||||||
if config().has_changed("notification_ignored_apps", old_config):
|
if config().has_changed("notification.ignored_apps", old_config):
|
||||||
ignored_apps = new_config.get("notification_ignored_apps", [])
|
ignored_apps = new_notif.get("ignored_apps", [])
|
||||||
ids_to_remove = [
|
ids_to_remove = [
|
||||||
cid
|
cid
|
||||||
for cid, cnotif in self._cached_notifications.items()
|
for cid, cnotif in self._cached_notifications.items()
|
||||||
@@ -254,8 +256,8 @@ class CachedNotifications(Notifications):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# If limited apps changed, prune duplicates
|
# If limited apps changed, prune duplicates
|
||||||
if config().has_changed("notification_limited_apps_history", old_config):
|
if config().has_changed("notification.limited_apps_history", old_config):
|
||||||
limited_apps = new_config.get("notification_limited_apps_history", [])
|
limited_apps = new_notif.get("limited_apps_history", [])
|
||||||
for app in limited_apps:
|
for app in limited_apps:
|
||||||
app_notifs = [
|
app_notifs = [
|
||||||
(cid, cnotif.timestamp)
|
(cid, cnotif.timestamp)
|
||||||
@@ -355,7 +357,7 @@ class CachedNotifications(Notifications):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Check if this app should be ignored for history (don't cache)
|
# Check if this app should be ignored for history (don't cache)
|
||||||
ignored_apps = config().get("notification_ignored_apps", [])
|
ignored_apps = config().get("notification.ignored_apps", [])
|
||||||
if notification.app_name in ignored_apps:
|
if notification.app_name in ignored_apps:
|
||||||
# Don't cache notifications from ignored apps, but still allow popup display
|
# Don't cache notifications from ignored apps, but still allow popup display
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@@ -395,7 +397,7 @@ class CachedNotifications(Notifications):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Handle limited history apps - remove previous notifications from same app
|
# Handle limited history apps - remove previous notifications from same app
|
||||||
limited_apps = config().get("notification_limited_apps_history", [])
|
limited_apps = config().get("notification.limited_apps_history", [])
|
||||||
if notification.app_name in limited_apps:
|
if notification.app_name in limited_apps:
|
||||||
ids_to_remove = [
|
ids_to_remove = [
|
||||||
cid
|
cid
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class KeyboardLayout(Service):
|
|||||||
self._set_current(0, emit=False)
|
self._set_current(0, emit=False)
|
||||||
|
|
||||||
def _load_layouts_from_config(self) -> list[str]:
|
def _load_layouts_from_config(self) -> list[str]:
|
||||||
layouts = get_config("keyboard_layouts", DEFAULT_LAYOUTS)
|
layouts = get_config("general.keyboard_layouts", DEFAULT_LAYOUTS)
|
||||||
if not isinstance(layouts, list) or not layouts:
|
if not isinstance(layouts, list) or not layouts:
|
||||||
return list(DEFAULT_LAYOUTS)
|
return list(DEFAULT_LAYOUTS)
|
||||||
return [str(layout).strip() for layout in layouts if str(layout).strip()]
|
return [str(layout).strip() for layout in layouts if str(layout).strip()]
|
||||||
@@ -199,7 +199,8 @@ class KeyboardLayout(Service):
|
|||||||
# config changes
|
# config changes
|
||||||
|
|
||||||
def _on_config_change(self, new_config, old_config):
|
def _on_config_change(self, new_config, old_config):
|
||||||
new_layouts = new_config.get("keyboard_layouts")
|
new_general = new_config.get("general", {})
|
||||||
|
new_layouts = new_general.get("keyboard_layouts")
|
||||||
if not isinstance(new_layouts, list) or not new_layouts:
|
if not isinstance(new_layouts, list) or not new_layouts:
|
||||||
return
|
return
|
||||||
new_layouts = [str(item).strip() for item in new_layouts if str(item).strip()]
|
new_layouts = [str(item).strip() for item in new_layouts if str(item).strip()]
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from fabric.utils import Gio, GLib, logger
|
|||||||
|
|
||||||
from services.config import get_config, on_config_change
|
from services.config import get_config, on_config_change
|
||||||
|
|
||||||
_CONFIG_KEY = "night_light_temperature"
|
_CONFIG_KEY = "panel.night_light_temperature"
|
||||||
_DEFAULT_TEMPERATURE = 4500
|
_DEFAULT_TEMPERATURE = 4500
|
||||||
_NEUTRAL_TEMPERATURE = 6000
|
_NEUTRAL_TEMPERATURE = 6000
|
||||||
_PROFILE_TEMP_RE = re.compile(r"(\d{3,5})")
|
_PROFILE_TEMP_RE = re.compile(r"(\d{3,5})")
|
||||||
@@ -106,9 +106,13 @@ class NightLightService(Service):
|
|||||||
self._sync_state()
|
self._sync_state()
|
||||||
|
|
||||||
def _on_config_change(self, new_config, old_config):
|
def _on_config_change(self, new_config, old_config):
|
||||||
if new_config.get(_CONFIG_KEY) == old_config.get(_CONFIG_KEY):
|
new_panel = new_config.get("panel", {})
|
||||||
|
old_panel = old_config.get("panel", {})
|
||||||
|
new_temp = new_panel.get("night_light_temperature")
|
||||||
|
old_temp = old_panel.get("night_light_temperature")
|
||||||
|
if new_temp == old_temp:
|
||||||
return
|
return
|
||||||
self.set_temperature(_coerce_temperature(new_config.get(_CONFIG_KEY)))
|
self.set_temperature(_coerce_temperature(new_temp))
|
||||||
|
|
||||||
def _set_active(self, value: bool):
|
def _set_active(self, value: bool):
|
||||||
if value != self._active:
|
if value != self._active:
|
||||||
|
|||||||
@@ -372,7 +372,9 @@ class Weather(Service):
|
|||||||
self.emit("ready")
|
self.emit("ready")
|
||||||
|
|
||||||
def _on_config_changed(self, new_config: dict, old_config: dict) -> None:
|
def _on_config_changed(self, new_config: dict, old_config: dict) -> None:
|
||||||
if new_config.get("weather_location") != old_config.get("weather_location"):
|
new_general = new_config.get("general", {})
|
||||||
|
old_general = old_config.get("general", {})
|
||||||
|
if new_general.get("weather_location") != old_general.get("weather_location"):
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def _start_fetch_thread(self) -> None:
|
def _start_fetch_thread(self) -> None:
|
||||||
@@ -387,7 +389,7 @@ class Weather(Service):
|
|||||||
|
|
||||||
from services.config import config
|
from services.config import config
|
||||||
|
|
||||||
target_loc = config().get("weather_location", "").strip()
|
target_loc = config().get("general.weather_location", "").strip()
|
||||||
|
|
||||||
# Invalidate location cache if the config target changed
|
# Invalidate location cache if the config target changed
|
||||||
if location_data and location_data.get("config_location", "") != target_loc:
|
if location_data and location_data.get("config_location", "") != target_loc:
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ def _get_wallpaper_path() -> str:
|
|||||||
try:
|
try:
|
||||||
from services.config import get_config
|
from services.config import get_config
|
||||||
|
|
||||||
custom = get_config("wallpapers_dir")
|
custom = get_config("general.wallpapers_dir")
|
||||||
if custom:
|
if custom:
|
||||||
expanded = os.path.expanduser(str(custom))
|
expanded = os.path.expanduser(str(custom))
|
||||||
if not os.path.isabs(expanded):
|
if not os.path.isabs(expanded):
|
||||||
|
|||||||
+42
-32
@@ -1,34 +1,44 @@
|
|||||||
DEFAULT = {
|
DEFAULT = {
|
||||||
"debug": False,
|
"general": {
|
||||||
"dock_enabled": True,
|
"debug": False,
|
||||||
"dock_auto_hide": True,
|
"wallpapers_dir": "src/assets/wallpaper_example/",
|
||||||
"dock_always_occluded": False,
|
"keyboard_layouts": ["us"],
|
||||||
"dock_icon_size": 52,
|
"weather_location": "",
|
||||||
"hide_special_workspace": True,
|
},
|
||||||
"dock_hide_special_workspace_apps": True,
|
"dock": {
|
||||||
"notification_timeout": "5s",
|
"enabled": True,
|
||||||
"notification_ignored_apps": ["Hyprshot"],
|
"auto_hide": True,
|
||||||
"notification_limited_apps_history": ["Spotify"],
|
"always_occluded": False,
|
||||||
"imac_button": True,
|
"icon_size": 52,
|
||||||
"systray": True,
|
"hide_special_workspace_apps": True,
|
||||||
"control_center": True,
|
},
|
||||||
"search": True,
|
"panel": {
|
||||||
"global_menu": True,
|
"imac_button": True,
|
||||||
"network": True,
|
"systray": True,
|
||||||
"battery": True,
|
"systray_ignore": ["blueman", "network"],
|
||||||
"notification_center": True,
|
"control_center": True,
|
||||||
"workspace_indicator": True,
|
"search": True,
|
||||||
"bluetooth": True,
|
"global_menu": True,
|
||||||
"date_time": True,
|
"network": True,
|
||||||
"night_light_temperature": 4500,
|
"battery": True,
|
||||||
"notch": True,
|
"notification_center": True,
|
||||||
"custom_mods": True,
|
"workspace_indicator": True,
|
||||||
"keyboard_layouts": ["us"],
|
"bluetooth": True,
|
||||||
"switcher_live_preview": True,
|
"date_time": True,
|
||||||
"switcher_live_preview_delay_ms": 200,
|
"night_light_temperature": 4500,
|
||||||
"systray_ignore": ["blueman", "network"],
|
"notch": True,
|
||||||
"wallpapers_dir": "src/assets/wallpaper_example/",
|
"osd": True,
|
||||||
"osd": True,
|
"hide_special_workspace": True,
|
||||||
"window_switcher": True,
|
"custom_mods": True,
|
||||||
"weather_location": "",
|
},
|
||||||
|
"switcher": {
|
||||||
|
"live_preview": True,
|
||||||
|
"live_preview_delay_ms": 200,
|
||||||
|
"window_switcher": True,
|
||||||
|
},
|
||||||
|
"notification": {
|
||||||
|
"timeout": "5s",
|
||||||
|
"ignored_apps": ["Hyprshot"],
|
||||||
|
"limited_apps_history": ["Spotify"],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ class DockCanvas(Gtk.DrawingArea):
|
|||||||
self.set_visual(visual)
|
self.set_visual(visual)
|
||||||
|
|
||||||
def _base_icon_size(self) -> int:
|
def _base_icon_size(self) -> int:
|
||||||
return int(config().get("dock_icon_size", 52))
|
return int(config().get("dock.icon_size", 52))
|
||||||
|
|
||||||
def _icon_cache_size(self) -> int:
|
def _icon_cache_size(self) -> int:
|
||||||
return int(self._base_icon_size() * MAX_SCALE)
|
return int(self._base_icon_size() * MAX_SCALE)
|
||||||
|
|||||||
+10
-10
@@ -69,7 +69,7 @@ class Dock(Window):
|
|||||||
|
|
||||||
on_config_change(self._on_config_change)
|
on_config_change(self._on_config_change)
|
||||||
|
|
||||||
if config().get("dock_auto_hide", True):
|
if config().get("dock.auto_hide", True):
|
||||||
self._setup_occlusion_signals()
|
self._setup_occlusion_signals()
|
||||||
self._check_occlusion_deferred()
|
self._check_occlusion_deferred()
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ class Dock(Window):
|
|||||||
try:
|
try:
|
||||||
if not config().get("dock_auto_hide", True):
|
if not config().get("dock_auto_hide", True):
|
||||||
return False
|
return False
|
||||||
is_occ = config().get("dock_always_occluded", False) or check_occlusion(
|
is_occ = config().get("dock.always_occluded", False) or check_occlusion(
|
||||||
("bottom", self.dock_height)
|
("bottom", self.dock_height)
|
||||||
)
|
)
|
||||||
if is_occ and not self.is_hovered and self.revealer.get_reveal_child():
|
if is_occ and not self.is_hovered and self.revealer.get_reveal_child():
|
||||||
@@ -119,24 +119,24 @@ class Dock(Window):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _on_config_change(self, new_config, old_config) -> None:
|
def _on_config_change(self, new_config, old_config) -> None:
|
||||||
if config().has_changed("dock_enabled", old_config):
|
if config().has_changed("dock.enabled", old_config):
|
||||||
self._update_visibility()
|
self._update_visibility()
|
||||||
|
|
||||||
if config().has_changed("dock_icon_size", old_config):
|
if config().has_changed("dock.icon_size", old_config):
|
||||||
self.canvas.update_icon_size()
|
self.canvas.update_icon_size()
|
||||||
|
|
||||||
if config().has_changed("dock_auto_hide", old_config):
|
if config().has_changed("dock.auto_hide", old_config):
|
||||||
if new_config.get("dock_auto_hide", True):
|
if new_config.get("dock.auto_hide", True):
|
||||||
self._setup_occlusion_signals()
|
self._setup_occlusion_signals()
|
||||||
else:
|
else:
|
||||||
self._disconnect_occlusion_signals()
|
self._disconnect_occlusion_signals()
|
||||||
self.revealer.set_reveal_child(True)
|
self.revealer.set_reveal_child(True)
|
||||||
|
|
||||||
if config().has_changed("dock_hide_special_workspace_apps", old_config):
|
if config().has_changed("dock.hide_special_workspace_apps", old_config):
|
||||||
self.canvas._rebuild_model()
|
self.canvas._rebuild_model()
|
||||||
|
|
||||||
def _update_visibility(self) -> None:
|
def _update_visibility(self) -> None:
|
||||||
if config().get("dock_enabled", True):
|
if config().get("dock.enabled", True):
|
||||||
self.show()
|
self.show()
|
||||||
self.revealer.set_reveal_child(True)
|
self.revealer.set_reveal_child(True)
|
||||||
else:
|
else:
|
||||||
@@ -154,9 +154,9 @@ class Dock(Window):
|
|||||||
|
|
||||||
def delayed_hide(t):
|
def delayed_hide(t):
|
||||||
if t == self.hide_ticket and not self.is_hovered:
|
if t == self.hide_ticket and not self.is_hovered:
|
||||||
if config().get("dock_auto_hide", True):
|
if config().get("dock.auto_hide", True):
|
||||||
is_occ = config().get(
|
is_occ = config().get(
|
||||||
"dock_always_occluded", False
|
"dock.always_occluded", False
|
||||||
) or check_occlusion(("bottom", self.dock_height))
|
) or check_occlusion(("bottom", self.dock_height))
|
||||||
if is_occ:
|
if is_occ:
|
||||||
self.revealer.set_reveal_child(False)
|
self.revealer.set_reveal_child(False)
|
||||||
|
|||||||
@@ -837,7 +837,7 @@ class NotificationWidget(Box):
|
|||||||
"""Get the current notification timeout from config manager."""
|
"""Get the current notification timeout from config manager."""
|
||||||
try:
|
try:
|
||||||
timeout_str = get_config(
|
timeout_str = get_config(
|
||||||
"notification_timeout", data.NOTIFICATION_TIMEOUT_STR
|
"notification.timeout", data.NOTIFICATION_TIMEOUT_STR
|
||||||
)
|
)
|
||||||
from shared.data import parse_timeout_string
|
from shared.data import parse_timeout_string
|
||||||
|
|
||||||
@@ -1472,13 +1472,13 @@ class ModusNoti(Window):
|
|||||||
def _apply_initial_config(self):
|
def _apply_initial_config(self):
|
||||||
try:
|
try:
|
||||||
timeout_val = get_config(
|
timeout_val = get_config(
|
||||||
"notification_timeout", data.NOTIFICATION_TIMEOUT_STR
|
"notification.timeout", data.NOTIFICATION_TIMEOUT_STR
|
||||||
)
|
)
|
||||||
ignored_apps = get_config(
|
ignored_apps = get_config(
|
||||||
"notification_ignored_apps", data.NOTIFICATION_IGNORED_APPS_HISTORY
|
"notification.ignored_apps", data.NOTIFICATION_IGNORED_APPS_HISTORY
|
||||||
)
|
)
|
||||||
limited_apps = get_config(
|
limited_apps = get_config(
|
||||||
"notification_limited_apps_history",
|
"notification.limited_apps_history",
|
||||||
data.NOTIFICATION_LIMITED_APPS_HISTORY,
|
data.NOTIFICATION_LIMITED_APPS_HISTORY,
|
||||||
)
|
)
|
||||||
initial = {
|
initial = {
|
||||||
@@ -1493,14 +1493,19 @@ class ModusNoti(Window):
|
|||||||
|
|
||||||
def _on_config_changed(self, new_config: dict, old_config: dict):
|
def _on_config_changed(self, new_config: dict, old_config: dict):
|
||||||
try:
|
try:
|
||||||
|
new_notif = new_config.get("notification", {})
|
||||||
|
old_notif = old_config.get("notification", {})
|
||||||
changes = {}
|
changes = {}
|
||||||
for key in (
|
key_map = {
|
||||||
"notification_timeout",
|
"timeout": "notification_timeout",
|
||||||
"notification_ignored_apps",
|
"ignored_apps": "notification_ignored_apps",
|
||||||
"notification_limited_apps_history",
|
"limited_apps_history": "notification_limited_apps_history",
|
||||||
):
|
}
|
||||||
if key in new_config and new_config.get(key) != old_config.get(key):
|
for new_key, local_key in key_map.items():
|
||||||
changes[key] = new_config.get(key)
|
if new_key in new_notif and new_notif.get(new_key) != old_notif.get(
|
||||||
|
new_key
|
||||||
|
):
|
||||||
|
changes[local_key] = new_notif.get(new_key)
|
||||||
|
|
||||||
if changes:
|
if changes:
|
||||||
self.update_config(changes)
|
self.update_config(changes)
|
||||||
|
|||||||
@@ -40,14 +40,14 @@ class OSD(Box):
|
|||||||
def show_audio_osd(self):
|
def show_audio_osd(self):
|
||||||
from services.config import get_config
|
from services.config import get_config
|
||||||
|
|
||||||
if not get_config("osd", True):
|
if not get_config("panel.osd", True):
|
||||||
return
|
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
|
from services.config import get_config
|
||||||
|
|
||||||
if not get_config("osd", True):
|
if not get_config("panel.osd", True):
|
||||||
return
|
return
|
||||||
self.show_container(self.containers.get("brightness"))
|
self.show_container(self.containers.get("brightness"))
|
||||||
|
|
||||||
@@ -71,13 +71,13 @@ class OSDWindow(Window):
|
|||||||
def osd_show_audio(self):
|
def osd_show_audio(self):
|
||||||
from services.config import get_config
|
from services.config import get_config
|
||||||
|
|
||||||
if not get_config("osd", True):
|
if not get_config("panel.osd", True):
|
||||||
return
|
return
|
||||||
self.osd.containers["audio"].update()
|
self.osd.containers["audio"].update()
|
||||||
|
|
||||||
def osd_show_brightness(self):
|
def osd_show_brightness(self):
|
||||||
from services.config import get_config
|
from services.config import get_config
|
||||||
|
|
||||||
if not get_config("osd", True):
|
if not get_config("panel.osd", True):
|
||||||
return
|
return
|
||||||
self.osd.containers["brightness"].update()
|
self.osd.containers["brightness"].update()
|
||||||
@@ -12,7 +12,7 @@ _tracked_items = weakref.WeakSet()
|
|||||||
|
|
||||||
def should_hide(item) -> bool:
|
def should_hide(item) -> bool:
|
||||||
"""Check if a tray item should be hidden based on config."""
|
"""Check if a tray item should be hidden based on config."""
|
||||||
ignore_list = get_config("systray_ignore", [])
|
ignore_list = get_config("panel.systray_ignore", [])
|
||||||
if not ignore_list:
|
if not ignore_list:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -29,25 +29,19 @@ class WorkspaceIndicator(Box):
|
|||||||
self._apply_initial_config()
|
self._apply_initial_config()
|
||||||
|
|
||||||
def _apply_initial_config(self):
|
def _apply_initial_config(self):
|
||||||
new_value = get_config("hide_special_workspace", True)
|
new_value = get_config("panel.hide_special_workspace", True)
|
||||||
if new_value != self._current_config["hide_special_workspace"]:
|
if new_value != self._current_config["hide_special_workspace"]:
|
||||||
self._current_config["hide_special_workspace"] = new_value
|
self._current_config["hide_special_workspace"] = new_value
|
||||||
self.update_config({"hide_special_workspace": new_value})
|
self.update_config({"hide_special_workspace": new_value})
|
||||||
|
|
||||||
def _on_config_changed(self, new_config: dict, old_config: dict):
|
def _on_config_changed(self, new_config: dict, old_config: dict):
|
||||||
if "hide_special_workspace" in new_config and new_config.get(
|
new_panel = new_config.get("panel", {})
|
||||||
"hide_special_workspace"
|
old_panel = old_config.get("panel", {})
|
||||||
) != old_config.get("hide_special_workspace"):
|
new_val = new_panel.get("hide_special_workspace", True)
|
||||||
self._current_config["hide_special_workspace"] = new_config.get(
|
old_val = old_panel.get("hide_special_workspace", True)
|
||||||
"hide_special_workspace", True
|
if new_val != old_val:
|
||||||
)
|
self._current_config["hide_special_workspace"] = new_val
|
||||||
self.update_config(
|
self.update_config({"hide_special_workspace": new_val})
|
||||||
{
|
|
||||||
"hide_special_workspace": self._current_config[
|
|
||||||
"hide_special_workspace"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def _get_button_factory(self):
|
def _get_button_factory(self):
|
||||||
if self._current_config.get("hide_special_workspace", True):
|
if self._current_config.get("hide_special_workspace", True):
|
||||||
|
|||||||
+24
-16
@@ -253,10 +253,12 @@ class Panel(Window):
|
|||||||
if config_data is None:
|
if config_data is None:
|
||||||
config_data = get_config_all()
|
config_data = get_config_all()
|
||||||
|
|
||||||
|
panel = config_data.get("panel", {})
|
||||||
|
|
||||||
# Update indicator visibility directly
|
# Update indicator visibility directly
|
||||||
battery_visible = config_data.get("battery", True)
|
battery_visible = panel.get("battery", True)
|
||||||
network_visible = config_data.get("network", True)
|
network_visible = panel.get("network", True)
|
||||||
bluetooth_visible = config_data.get("bluetooth", True)
|
bluetooth_visible = panel.get("bluetooth", True)
|
||||||
|
|
||||||
self.battery_indicator.set_visible(battery_visible)
|
self.battery_indicator.set_visible(battery_visible)
|
||||||
self.network_indicator.set_visible(network_visible)
|
self.network_indicator.set_visible(network_visible)
|
||||||
@@ -271,16 +273,16 @@ class Panel(Window):
|
|||||||
self.bluetooth_indicator.update_state()
|
self.bluetooth_indicator.update_state()
|
||||||
|
|
||||||
# Center (notch)
|
# Center (notch)
|
||||||
if config_data.get("notch", True):
|
if panel.get("notch", True):
|
||||||
self.center_box.children = [self.notch]
|
self.center_box.children = [self.notch]
|
||||||
else:
|
else:
|
||||||
self.center_box.children = []
|
self.center_box.children = []
|
||||||
|
|
||||||
# Left
|
# Left
|
||||||
left_children = []
|
left_children = []
|
||||||
if config_data.get("imac_button", True):
|
if panel.get("imac_button", True):
|
||||||
left_children.append(self.imac)
|
left_children.append(self.imac)
|
||||||
if config_data.get("global_menu", True):
|
if panel.get("global_menu", True):
|
||||||
left_children.append(self.globalmenu)
|
left_children.append(self.globalmenu)
|
||||||
|
|
||||||
for child in left_children:
|
for child in left_children:
|
||||||
@@ -289,23 +291,23 @@ class Panel(Window):
|
|||||||
|
|
||||||
# Right
|
# Right
|
||||||
right_children = []
|
right_children = []
|
||||||
if config_data.get("custom_mods", True):
|
if panel.get("custom_mods", True):
|
||||||
right_children.append(self.custom_mods)
|
right_children.append(self.custom_mods)
|
||||||
if config_data.get("workspace_indicator", True):
|
if panel.get("workspace_indicator", True):
|
||||||
right_children.append(self.workspace_indicator)
|
right_children.append(self.workspace_indicator)
|
||||||
|
|
||||||
if config_data.get("systray", True):
|
if panel.get("systray", True):
|
||||||
right_children.extend([self.tray_revealer, self.chevron_button])
|
right_children.extend([self.tray_revealer, self.chevron_button])
|
||||||
|
|
||||||
right_children.append(self.indicators)
|
right_children.append(self.indicators)
|
||||||
|
|
||||||
if config_data.get("search", True):
|
if panel.get("search", True):
|
||||||
right_children.append(self.search)
|
right_children.append(self.search)
|
||||||
if config_data.get("control_center", True):
|
if panel.get("control_center", True):
|
||||||
right_children.append(self.control_center_btn)
|
right_children.append(self.control_center_btn)
|
||||||
if config_data.get("date_time", True):
|
if panel.get("date_time", True):
|
||||||
right_children.append(self.datetime_btn)
|
right_children.append(self.datetime_btn)
|
||||||
if config_data.get("notification_center", True):
|
if panel.get("notification_center", True):
|
||||||
right_children.append(self.notification_center_btn)
|
right_children.append(self.notification_center_btn)
|
||||||
|
|
||||||
for child in right_children:
|
for child in right_children:
|
||||||
@@ -321,11 +323,13 @@ class Panel(Window):
|
|||||||
|
|
||||||
def _on_config_changed(self, new_config, old_config):
|
def _on_config_changed(self, new_config, old_config):
|
||||||
logger.debug("Config changed, checking keys...")
|
logger.debug("Config changed, checking keys...")
|
||||||
keys = {
|
new_panel = new_config.get("panel", {})
|
||||||
|
old_panel = old_config.get("panel", {})
|
||||||
|
|
||||||
|
panel_keys = {
|
||||||
"imac_button",
|
"imac_button",
|
||||||
"global_menu",
|
"global_menu",
|
||||||
"notch",
|
"notch",
|
||||||
"custom_mods",
|
|
||||||
"workspace_indicator",
|
"workspace_indicator",
|
||||||
"systray",
|
"systray",
|
||||||
"battery",
|
"battery",
|
||||||
@@ -335,8 +339,12 @@ class Panel(Window):
|
|||||||
"control_center",
|
"control_center",
|
||||||
"date_time",
|
"date_time",
|
||||||
"notification_center",
|
"notification_center",
|
||||||
|
"custom_mods",
|
||||||
|
"hide_special_workspace",
|
||||||
}
|
}
|
||||||
changed_keys = [k for k in keys if new_config.get(k) != old_config.get(k)]
|
|
||||||
|
changed_keys = [k for k in panel_keys if new_panel.get(k) != old_panel.get(k)]
|
||||||
|
|
||||||
if changed_keys:
|
if changed_keys:
|
||||||
logger.debug(f"Rebuilding due to changes in: {changed_keys}")
|
logger.debug(f"Rebuilding due to changes in: {changed_keys}")
|
||||||
self._rebuild_layout_from_config(new_config)
|
self._rebuild_layout_from_config(new_config)
|
||||||
|
|||||||
+31
-31
@@ -335,37 +335,37 @@ class SettingsWindow(Gtk.Window):
|
|||||||
[
|
[
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Debug Mode",
|
"Debug Mode",
|
||||||
SettingsSwitch("debug"),
|
SettingsSwitch("general.debug"),
|
||||||
"Enable verbose logging for development",
|
"Enable verbose logging for development",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Weather Location",
|
"Weather Location",
|
||||||
SettingsEntry("weather_location"),
|
SettingsEntry("general.weather_location"),
|
||||||
"City name for weather updates",
|
"City name for weather updates",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Keyboard Layouts",
|
"Keyboard Layouts",
|
||||||
SettingsList("keyboard_layouts"),
|
SettingsList("general.keyboard_layouts"),
|
||||||
"Manage active keyboard input languages",
|
"Manage active keyboard input languages",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Hide Special Workspace",
|
"Hide Special Workspace",
|
||||||
SettingsSwitch("hide_special_workspace"),
|
SettingsSwitch("panel.hide_special_workspace"),
|
||||||
"Don't show special workspace in indicators",
|
"Don't show special workspace in indicators",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Night Light Temperature",
|
"Night Light Temperature",
|
||||||
SettingsEntry("night_light_temperature"),
|
SettingsEntry("panel.night_light_temperature"),
|
||||||
"Color temperature in Kelvin (e.g. 4500)",
|
"Color temperature in Kelvin (e.g. 4500)",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Live Preview",
|
"Live Preview",
|
||||||
SettingsSwitch("switcher_live_preview"),
|
SettingsSwitch("switcher.live_preview"),
|
||||||
"Show live window previews in switcher",
|
"Show live window previews in switcher",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Preview Delay (ms)",
|
"Preview Delay (ms)",
|
||||||
SettingsEntry("switcher_live_preview_delay_ms"),
|
SettingsEntry("switcher.live_preview_delay_ms"),
|
||||||
"Delay before live preview appears",
|
"Delay before live preview appears",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -377,27 +377,27 @@ class SettingsWindow(Gtk.Window):
|
|||||||
[
|
[
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Enabled",
|
"Enabled",
|
||||||
SettingsSwitch("dock_enabled"),
|
SettingsSwitch("dock.enabled"),
|
||||||
"Show the application dock",
|
"Show the application dock",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Auto Hide",
|
"Auto Hide",
|
||||||
SettingsSwitch("dock_auto_hide"),
|
SettingsSwitch("dock.auto_hide"),
|
||||||
"Hide dock when not in use",
|
"Hide dock when not in use",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Always Occluded",
|
"Always Occluded",
|
||||||
SettingsSwitch("dock_always_occluded"),
|
SettingsSwitch("dock.always_occluded"),
|
||||||
"Keep dock behind other windows",
|
"Keep dock behind other windows",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Icon Size",
|
"Icon Size",
|
||||||
SettingsEntry("dock_icon_size"),
|
SettingsEntry("dock.icon_size"),
|
||||||
"Size of dock icons in pixels",
|
"Size of dock icons in pixels",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Hide Special Apps",
|
"Hide Special Apps",
|
||||||
SettingsSwitch("dock_hide_special_workspace_apps"),
|
SettingsSwitch("dock.hide_special_workspace_apps"),
|
||||||
"Hide apps from special workspace in dock",
|
"Hide apps from special workspace in dock",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -407,72 +407,72 @@ class SettingsWindow(Gtk.Window):
|
|||||||
rows = [
|
rows = [
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Global Menu",
|
"Global Menu",
|
||||||
SettingsSwitch("global_menu"),
|
SettingsSwitch("panel.global_menu"),
|
||||||
"Show application menu in the panel",
|
"Show application menu in the panel",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"iMac Button",
|
"iMac Button",
|
||||||
SettingsSwitch("imac_button"),
|
SettingsSwitch("panel.imac_button"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Systray",
|
"Systray",
|
||||||
SettingsSwitch("systray"),
|
SettingsSwitch("panel.systray"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Control Center",
|
"Control Center",
|
||||||
SettingsSwitch("control_center"),
|
SettingsSwitch("panel.control_center"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Search",
|
"Search",
|
||||||
SettingsSwitch("search"),
|
SettingsSwitch("panel.search"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Network",
|
"Network",
|
||||||
SettingsSwitch("network"),
|
SettingsSwitch("panel.network"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Battery",
|
"Battery",
|
||||||
SettingsSwitch("battery"),
|
SettingsSwitch("panel.battery"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Bluetooth",
|
"Bluetooth",
|
||||||
SettingsSwitch("bluetooth"),
|
SettingsSwitch("panel.bluetooth"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Date & Time",
|
"Date & Time",
|
||||||
SettingsSwitch("date_time"),
|
SettingsSwitch("panel.date_time"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Workspace Indicator",
|
"Workspace Indicator",
|
||||||
SettingsSwitch("workspace_indicator"),
|
SettingsSwitch("panel.workspace_indicator"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Notification Center",
|
"Notification Center",
|
||||||
SettingsSwitch("notification_center"),
|
SettingsSwitch("panel.notification_center"),
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Custom Mods",
|
"Custom Mods",
|
||||||
SettingsSwitch("custom_mods"),
|
SettingsSwitch("panel.custom_mods"),
|
||||||
"Enable custom Hyprland mods in panel",
|
"Enable custom Hyprland mods in panel",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Window Switcher",
|
"Window Switcher",
|
||||||
SettingsSwitch("window_switcher"),
|
SettingsSwitch("switcher.window_switcher"),
|
||||||
"Enable Alt+Tab window switcher",
|
"Enable Alt+Tab window switcher",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"OSD",
|
"OSD",
|
||||||
SettingsSwitch("osd"),
|
SettingsSwitch("panel.osd"),
|
||||||
"Enable on-screen display for volume/brightness",
|
"Enable on-screen display for volume/brightness",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Wallpapers Directory",
|
"Wallpapers Directory",
|
||||||
SettingsEntry("wallpapers_dir"),
|
SettingsEntry("general.wallpapers_dir"),
|
||||||
"Path to wallpapers folder",
|
"Path to wallpapers folder",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Systray Ignore",
|
"Systray Ignore",
|
||||||
SettingsList("systray_ignore"),
|
SettingsList("panel.systray_ignore"),
|
||||||
"Icons to hide from the system tray",
|
"Icons to hide from the system tray",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -485,17 +485,17 @@ class SettingsWindow(Gtk.Window):
|
|||||||
[
|
[
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Timeout",
|
"Timeout",
|
||||||
SettingsEntry("notification_timeout"),
|
SettingsEntry("notification.timeout"),
|
||||||
"How long notifications stay on screen (e.g. 5s)",
|
"How long notifications stay on screen (e.g. 5s)",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Ignored Apps",
|
"Ignored Apps",
|
||||||
SettingsList("notification_ignored_apps"),
|
SettingsList("notification.ignored_apps"),
|
||||||
"Apps that won't show notifications",
|
"Apps that won't show notifications",
|
||||||
),
|
),
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
"Limited History",
|
"Limited History",
|
||||||
SettingsList("notification_limited_apps_history"),
|
SettingsList("notification.limited_apps_history"),
|
||||||
"Apps with only the latest notification shown",
|
"Apps with only the latest notification shown",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -120,9 +120,9 @@ class ApplicationSwitcher(Window):
|
|||||||
self.set_visible(False)
|
self.set_visible(False)
|
||||||
|
|
||||||
def _on_config_changed(self, new_config, old_config):
|
def _on_config_changed(self, new_config, old_config):
|
||||||
preview_changed = config().has_changed("switcher_live_preview", old_config)
|
preview_changed = config().has_changed("switcher.live_preview", old_config)
|
||||||
if (
|
if (
|
||||||
config().has_changed("hide_special_workspace", old_config)
|
config().has_changed("panel.hide_special_workspace", old_config)
|
||||||
or preview_changed
|
or preview_changed
|
||||||
):
|
):
|
||||||
if preview_changed:
|
if preview_changed:
|
||||||
@@ -133,7 +133,7 @@ class ApplicationSwitcher(Window):
|
|||||||
self._rebuild()
|
self._rebuild()
|
||||||
|
|
||||||
def show_switcher(self) -> None:
|
def show_switcher(self) -> None:
|
||||||
if not config().get("window_switcher", True):
|
if not config().get("switcher.window_switcher", True):
|
||||||
return
|
return
|
||||||
self._rebuild()
|
self._rebuild()
|
||||||
if not self.windows:
|
if not self.windows:
|
||||||
@@ -180,7 +180,7 @@ class ApplicationSwitcher(Window):
|
|||||||
return pixbuf
|
return pixbuf
|
||||||
|
|
||||||
def _create_item(self) -> _SwitcherItem:
|
def _create_item(self) -> _SwitcherItem:
|
||||||
use_preview = config().get("switcher_live_preview", True)
|
use_preview = config().get("switcher.live_preview", True)
|
||||||
|
|
||||||
if use_preview:
|
if use_preview:
|
||||||
app_icon = Image(name="app-switcher-app-icon")
|
app_icon = Image(name="app-switcher-app-icon")
|
||||||
@@ -300,7 +300,7 @@ class ApplicationSwitcher(Window):
|
|||||||
item.button.set_visible(False)
|
item.button.set_visible(False)
|
||||||
return
|
return
|
||||||
|
|
||||||
hide_special = config().get("hide_special_workspace", True)
|
hide_special = config().get("panel.hide_special_workspace", True)
|
||||||
filtered = []
|
filtered = []
|
||||||
for c in clients:
|
for c in clients:
|
||||||
if c.get("hidden", False):
|
if c.get("hidden", False):
|
||||||
@@ -333,7 +333,7 @@ class ApplicationSwitcher(Window):
|
|||||||
)
|
)
|
||||||
self.current_index = idx
|
self.current_index = idx
|
||||||
|
|
||||||
use_preview = config().get("switcher_live_preview", True)
|
use_preview = config().get("switcher.live_preview", True)
|
||||||
|
|
||||||
display = Gdk.Display.get_default()
|
display = Gdk.Display.get_default()
|
||||||
monitor = display.get_primary_monitor() if display else None
|
monitor = display.get_primary_monitor() if display else None
|
||||||
@@ -430,7 +430,7 @@ class ApplicationSwitcher(Window):
|
|||||||
self._update_selection()
|
self._update_selection()
|
||||||
self._addr_to_idx = {w["address"]: i for i, w in enumerate(self.windows)}
|
self._addr_to_idx = {w["address"]: i for i, w in enumerate(self.windows)}
|
||||||
|
|
||||||
use_preview = config().get("switcher_live_preview", True)
|
use_preview = config().get("switcher.live_preview", True)
|
||||||
if use_preview:
|
if use_preview:
|
||||||
self._capture_queue = [w["address"] for w in self.windows]
|
self._capture_queue = [w["address"] for w in self.windows]
|
||||||
self._current_capture_addr = None
|
self._current_capture_addr = None
|
||||||
@@ -574,7 +574,7 @@ class ApplicationSwitcher(Window):
|
|||||||
item.preview_image.set_from_pixbuf(pixbuf)
|
item.preview_image.set_from_pixbuf(pixbuf)
|
||||||
|
|
||||||
if self.get_visible() and config().get("switcher_live_preview", True):
|
if self.get_visible() and config().get("switcher_live_preview", True):
|
||||||
fps_delay = config().get("switcher_live_preview_delay_ms", 200)
|
fps_delay = config().get("switcher.live_preview_delay_ms", 200)
|
||||||
invoke_repeater(
|
invoke_repeater(
|
||||||
fps_delay,
|
fps_delay,
|
||||||
lambda: (
|
lambda: (
|
||||||
@@ -604,7 +604,7 @@ class ApplicationSwitcher(Window):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _pump_capture_queue(self):
|
def _pump_capture_queue(self):
|
||||||
use_preview = config().get("switcher_live_preview", True)
|
use_preview = config().get("switcher.live_preview", True)
|
||||||
if not use_preview:
|
if not use_preview:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user