Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/widgets/(Widget)-GlazeWM-Workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
| `offline_label` | string | `'GlazeWM Offline'` | The label to display when GlazeWM is offline. |
| `populated_label` | string | `'{name}'` | Optional label for populated workspaces. |
| `empty_label` | string | `'{name}'` | Optional label for empty workspaces. |
| `active_populated_label` | string | `'{name}'` | Optional label for the currently focused workspace (has opened windows). |
| `active_empty_label` | string | `'{name}'` | Optional label for the currently focused workspace (has no windows opened). |
| `hide_empty_workspaces` | boolean | `true` | Whether to hide empty workspaces. |
| `hide_if_offline` | boolean | `false` | Whether to hide workspaces widget if GlazeWM is offline. |
| `glazewm_server_uri` | string | `'ws://localhost:6123'` | Optional GlazeWM server uri. |
Expand Down Expand Up @@ -44,6 +46,8 @@ glazewm_workspaces:
- **offline_label:** The label to display when GlazeWM is offline.
- **populated_label:** Optional label for populated workspaces. If not set, name or display_name from GlazeWM will be used.
- **empty_label:** Optional label for empty workspaces. If not set, name or display_name from GlazeWM will be used.
- **active_populated_label:** Optional label for the currently focused workspace (has windows opened). If not set, name or display_name from GlazeWM will be used.
- **active_empty_label:** Optional label for the currently focused workspace (has no windows opened). If not set, name or display_name from GlazeWM will be used.
- **hide_empty_workspaces:** Whether to hide empty workspaces.
- **hide_if_offline:** Whether to hide workspaces widget if GlazeWM is offline.
- **glazewm_server_uri:** Optional GlazeWM server uri if it ever changes on GlazeWM side.
Expand Down
12 changes: 12 additions & 0 deletions src/core/validation/widgets/glazewm/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"offline_label": "GlazeWM Offline",
"populated_label": None,
"empty_label": None,
"active_populated_label": None,
"active_empty_label": None,
"hide_empty_workspaces": True,
"hide_if_offline": False,
"glazewm_server_uri": "ws://localhost:6123",
Expand Down Expand Up @@ -29,6 +31,16 @@
"default": DEFAULTS["empty_label"],
"nullable": True,
},
"active_populated_label": {
"type": "string",
"default": DEFAULTS["active_populated_label"],
"nullable": True,
},
"active_empty_label": {
"type": "string",
"default": DEFAULTS["active_empty_label"],
"nullable": True,
},
"hide_empty_workspaces": {
"type": "boolean",
"default": DEFAULTS["hide_empty_workspaces"],
Expand Down
18 changes: 16 additions & 2 deletions src/core/widgets/glazewm/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def __init__(
display_name: str | None = None,
populated_label: str | None = None,
empty_label: str | None = None,
active_populated_label: str | None = None,
active_empty_label: str | None = None,
):
super().__init__()
self.setProperty("class", "ws-btn")
Expand All @@ -52,6 +54,8 @@ def __init__(
self.display_name = display_name
self.populated_label = populated_label
self.empty_label = empty_label
self.active_populated_label = active_populated_label
self.active_empty_label = active_empty_label
self.is_displayed = False
self.workspace_window_count = 0
self.status = WorkspaceStatus.EMPTY
Expand Down Expand Up @@ -85,14 +89,18 @@ def _update_label(self):
# Label priority: YASB config -> display_name from GlazeWM -> name from GlazeWM
populated_label = self.populated_label or self.display_name or self.workspace_name
empty_label = self.empty_label or self.display_name or self.workspace_name
active_populated_label = self.active_populated_label or self.display_name or self.workspace_name
active_empty_label = self.active_empty_label or self.display_name or self.workspace_name
# Replace placeholders if any exist
populated_label = populated_label.format_map(replacements)
empty_label = empty_label.format_map(replacements)
active_populated_label = active_populated_label.format_map(replacements)
active_empty_label = active_empty_label.format_map(replacements)
if self.status == WorkspaceStatus.ACTIVE:
if self.workspace_window_count > 0:
self.setText(populated_label)
self.setText(active_populated_label)
else:
self.setText(empty_label)
self.setText(active_empty_label)
self.setHidden(False)
elif self.status == WorkspaceStatus.POPULATED:
self.setText(populated_label)
Expand All @@ -111,6 +119,8 @@ def __init__(
offline_label: str,
populated_label: str,
empty_label: str,
active_populated_label: str,
active_empty_label: str,
hide_empty_workspaces: bool,
hide_if_offline: bool,
container_padding: dict,
Expand All @@ -122,6 +132,8 @@ def __init__(
self.label_offline = offline_label
self.populated_label = populated_label
self.empty_label = empty_label
self.active_populated_label = active_populated_label
self.active_empty_label = active_empty_label
self.glazewm_server_uri = glazewm_server_uri
self.hide_empty_workspaces = hide_empty_workspaces
self.hide_if_offline = hide_if_offline
Expand Down Expand Up @@ -190,6 +202,8 @@ def _update_workspaces(self, message: list[Monitor]):
display_name=workspace.display_name,
populated_label=self.populated_label,
empty_label=self.empty_label,
active_populated_label=self.active_populated_label,
active_empty_label=self.active_empty_label,
)
add_shadow(btn, self.btn_shadow)

Expand Down