Files
Modus/src/window/panel/components/workspace.py
T
sankalp e4813f35a0 feat(root): implement dynamic todo list refresh and UI enhancements
This change adds a mechanism to refresh the todo list dynamically when the underlying service updates, improving UI responsiveness and user experience. It also updates documentation and removes deprecated files.

- New Features:
  - Added `_refresh_todos` method to rebuild the todo list when `get_todo_service().todos` changes.
  - Introduced `TodoListCapture` class for mouse capture handling of the todo list window.
- Enhancements:
  - Updated README with corrected image paths, installation tips, and manual installation commands.
  - Introduced `start.py` to launch the application or lock mode.
  - Removed deprecated `config.json` and `debug_memory.py`.
- Bug Fixes:
  - Fixed lock screen screenshot path in README.
2026-04-10 17:11:32 +05:45

80 lines
2.8 KiB
Python

from fabric.hyprland.widgets import HyprlandWorkspaces, WorkspaceButton
from fabric.widgets.box import Box
from services.config import get_config, on_config_change
from utils.functions import is_special_workspace_id
from utils.utils import setup_cursor_hover
# TODO: Support multi-monitor setups
class WorkspaceIndicator(Box):
def __init__(self, **kwargs):
Box.__init__(
self, name="workspace-indicator", orientation="h", spacing=4, **kwargs
)
self._current_config = {"hide_special_workspace": True}
on_config_change(self._on_config_changed)
self.workspaces = HyprlandWorkspaces(
name="workspaces",
spacing=4,
buttons_factory=self._get_button_factory(),
)
self.add(self.workspaces)
self.show_all()
self._apply_initial_config()
def _apply_initial_config(self):
new_value = get_config("hide_special_workspace", True)
if new_value != self._current_config["hide_special_workspace"]:
self._current_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):
if "hide_special_workspace" in new_config and new_config.get(
"hide_special_workspace"
) != old_config.get("hide_special_workspace"):
self._current_config["hide_special_workspace"] = new_config.get(
"hide_special_workspace", True
)
self.update_config(
{
"hide_special_workspace": self._current_config[
"hide_special_workspace"
]
}
)
def _get_button_factory(self):
if self._current_config.get("hide_special_workspace", True):
return self._create_filtered_button
else:
return lambda ws_id: self._create_button_with_hover(ws_id)
def _create_filtered_button(self, ws_id):
if self._current_config.get(
"hide_special_workspace", True
) and is_special_workspace_id(ws_id):
return None
return self._create_button_with_hover(ws_id)
def _create_button_with_hover(self, ws_id):
button = WorkspaceButton(id=ws_id, label=str(ws_id))
setup_cursor_hover(button, "pointer")
return button
def update_config(self, new_config: dict):
if "hide_special_workspace" in new_config:
button_factory = self._get_button_factory()
self.remove(self.workspaces)
self.workspaces = HyprlandWorkspaces(
name="workspaces",
spacing=4,
buttons_factory=button_factory,
)
self.add(self.workspaces)
self.workspaces.show_all()