diff --git a/hyprmod/binds/dialog.py b/hyprmod/binds/dialog.py index 7be7e11..52051c4 100644 --- a/hyprmod/binds/dialog.py +++ b/hyprmod/binds/dialog.py @@ -33,14 +33,6 @@ KEY_BIND_TYPE_KEYS = list(KEY_BIND_TYPES.keys()) KEY_BIND_TYPE_LABELS = [v["label"] for v in KEY_BIND_TYPES.values()] -# UI-specific filtered views: exclude the catch-all "advanced" group AND the -# bindm-only "mouse_button" group — the latter has its own trigger mode and -# isn't selectable from the keyboard-action category combo. -DIALOG_CATEGORIES = [ - c for c in DISPATCHER_CATEGORIES if c["id"] not in ("advanced", "mouse_button") -] -DIALOG_CATEGORY_LABELS = [c["label"] for c in DIALOG_CATEGORIES] - # bindm dispatcher list ordered by definition in BINDM_DISPATCHERS. _BINDM_DISPATCHER_KEYS = list(BINDM_DISPATCHERS.keys()) _BINDM_DISPATCHER_LABELS = list(BINDM_DISPATCHERS.values()) @@ -250,6 +242,19 @@ def __init__( else: self._is_mouse_mode = False + self._dialog_categories = [] + for c in DISPATCHER_CATEGORIES: + if c["id"] in ("advanced", "mouse_button"): + continue + if c["id"] == "plugins": + app_state = getattr(self._window, "app_state", {}) + state = app_state.get("plugin:dynamic_cursors:enabled") + if state is None or not state.available or not bool(state.live_value): + continue + self._dialog_categories.append(c) + + self._dialog_category_labels = [c["label"] for c in self._dialog_categories] + self.connect("closed", self._on_dialog_closed) self.set_title("Add Keybind" if self._is_new else "Edit Keybind") @@ -728,15 +733,15 @@ def _build_action_section(self, group): if self._is_new and self._initial_category: current_cat_id = self._initial_category self._category_combo = Adw.ComboRow( - title="Category", model=Gtk.StringList.new(DIALOG_CATEGORY_LABELS) + title="Category", model=Gtk.StringList.new(self._dialog_category_labels) ) - dialog_cat_ids = [c["id"] for c in DIALOG_CATEGORIES] + dialog_cat_ids = [c["id"] for c in self._dialog_categories] if current_cat_id in dialog_cat_ids: self._category_combo.set_selected(dialog_cat_ids.index(current_cat_id)) effective_cat_id = current_cat_id else: self._category_combo.set_selected(0) - effective_cat_id = DIALOG_CATEGORIES[0]["id"] + effective_cat_id = self._dialog_categories[0]["id"] self._sig_category = self._category_combo.connect( "notify::selected", self._on_category_changed ) @@ -773,9 +778,9 @@ def on_bind(_factory, list_item): def _get_selected_category(self) -> DispatcherCategory: idx = self._category_combo.get_selected() - if 0 <= idx < len(DIALOG_CATEGORIES): - return DIALOG_CATEGORIES[idx] - return DIALOG_CATEGORIES[0] + if 0 <= idx < len(self._dialog_categories): + return self._dialog_categories[idx] + return self._dialog_categories[0] def _update_action_model(self, category_id: str, select_dispatcher: str = ""): self._action_combo.handler_block(self._sig_action) diff --git a/hyprmod/binds/dispatchers.py b/hyprmod/binds/dispatchers.py index b8d3bb2..2eb2f57 100644 --- a/hyprmod/binds/dispatchers.py +++ b/hyprmod/binds/dispatchers.py @@ -233,6 +233,17 @@ class DispatcherCategory(TypedDict): "submap": {"label": "Enter submap", "arg_type": "text"}, }, }, + { + "id": "plugins", + "label": "Plugins", + "icon": "application-x-addon-symbolic", + "dispatchers": { + "plugin:dynamic-cursors:magnify": { + "label": "Magnify Cursor (Hypr Dynamic Cursors)", + "arg_type": "optional_text", + }, + }, + }, { "id": "advanced", "label": "Other",