✨ feat(panel): add option to hide special workspaces in workspace indicator

This commit is contained in:
sankalp committed 2025-08-11 18:16:12 +05:45
1 parent fccb44b208
commit 28a40e69b0
2 files changed
+45 -29

No files matched your search

+4 -15
View File
@@ -60,12 +60,6 @@ WALLPAPERS_DIR_DEFAULT = os.path.expanduser(f"~/Pictures/Wallpapers/")
CONFIG_FILE = get_relative_path("../config/assets/config.json")
MATUGEN_STATE_FILE = os.path.join(CONFIG_DIR, "matugen")
WORKSPACE_NUMS = False
WORKSPACE_USE_CHINESE_NUMERAL = False
WORKSPACE_DOTS = False
DOCK_THEME = "Pills"
def load_config():
"""Load the configuration from config.json"""
@@ -86,17 +80,13 @@ if os.path.exists(CONFIG_FILE):
config = json.load(f)
WALLPAPERS_DIR = config.get("wallpapers_dir", WALLPAPERS_DIR_DEFAULT)
DOCK_POSITION = config.get("dock_position", "Bottom")
VERTICAL = DOCK_POSITION in ["Left", "Right"]
TERMINAL_COMMAND = config.get("terminal_command", "kitty -e")
DOCK_ENABLED = config.get("dock_enabled", True)
DOCK_AUTO_HIDE = config.get("dock_auto_hide", True)
DOCK_ALWAYS_OCCLUDED = config.get("dock_always_occluded", False)
DOCK_ICON_SIZE = config.get("dock_icon_size", 60)
WORKSPACE_NUMS = config.get("workspace_nums", False)
WORKSPACE_USE_CHINESE_NUMERAL = config.get("workspace_use_chinese_numerals", False)
WORKSPACE_DOTS = config.get("workspace_dots", False)
WINDOW_SWITCHER_ITEMS_PER_ROW = config.get("window_switcher_items_per_row", 13)
DOCK_HIDE_SPECIAL_WORKSPACE = config.get("dock_hide_special_workspace", True)
WINDOW_SWITCHER_ITEMS_PER_ROW = config.get("window_switcher_items_per_row", 10)
HIDE_SPECIAL_WORKSPACE = config.get("hide_special_workspace", True)
DOCK_HIDE_SPECIAL_WORKSPACE_APPS = config.get(
"dock_hide_special_workspace_apps", True
)
@@ -127,15 +117,14 @@ if os.path.exists(CONFIG_FILE):
else:
WALLPAPERS_DIR = WALLPAPERS_DIR_DEFAULT
DOCK_POSITION = "Bottom"
VERTICAL = False
DOCK_ENABLED = True
DOCK_ALWAYS_OCCLUDED = False
DOCK_AUTO_HIDE = True
TERMINAL_COMMAND = "kitty -e"
DOCK_THEME = "Pills"
DOCK_ICON_SIZE = 60
WINDOW_SWITCHER_ITEMS_PER_ROW = 13
DOCK_HIDE_SPECIAL_WORKSPACE = True
WINDOW_SWITCHER_ITEMS_PER_ROW = 10
HIDE_SPECIAL_WORKSPACE = True
DOCK_HIDE_SPECIAL_WORKSPACE_APPS = True
DOCK_PREVIEW_APPS = False
+41 -14
View File
@@ -1,25 +1,52 @@
from fabric.hyprland.widgets import HyprlandWorkspaces, WorkspaceButton
from fabric.widgets.box import Box
import config.data as data
# TODO: Support Multi Monitor
class WorkspaceIndicator(Box):
def __init__(self, **kwargs):
super().__init__(
name="workspace-indicator",
orientation="h",
spacing=4,
**kwargs
name="workspace-indicator", orientation="h", spacing=4, **kwargs
)
self.workspaces = HyprlandWorkspaces(
name="workspaces",
spacing=4,
buttons_factory=lambda ws_id: WorkspaceButton(
id=ws_id,
label=str(ws_id)
),
)
# Create workspace widget with custom button factory if filtering is enabled
if data.HIDE_SPECIAL_WORKSPACE:
self.workspaces = HyprlandWorkspaces(
name="workspaces",
spacing=4,
buttons_factory=self._create_filtered_button,
)
else:
self.workspaces = HyprlandWorkspaces(
name="workspaces",
spacing=4,
buttons_factory=lambda ws_id: WorkspaceButton(
id=ws_id, label=str(ws_id)
),
)
self.add(self.workspaces)
self.show_all()
def _is_special_workspace_id(self, ws_id):
"""Check if a workspace ID represents a special workspace"""
try:
# Convert to int if it's a string
workspace_id = int(ws_id)
# Special workspaces have negative IDs
return workspace_id < 0
except (ValueError, TypeError):
# If it's a string, check if it starts with "special:"
if isinstance(ws_id, str) and ws_id.startswith("special:"):
return True
return False
def _create_filtered_button(self, ws_id):
"""Create workspace button only if it should be shown"""
if data.HIDE_SPECIAL_WORKSPACE and self._is_special_workspace_id(ws_id):
# Return None or an empty widget to hide special workspaces
return None
return WorkspaceButton(id=ws_id, label=str(ws_id))