From ed6a42bcace45203385e0a1126fa1d72b1e64c29 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Fri, 28 Aug 2026 04:01:22 +0530 Subject: desktop: showing tooltip on hover for workspace buttons --- modules/desktop/eww/workspaces.py | 21 +++++++++++++++++++++ modules/desktop/eww/yuck.nix | 1 + 2 files changed, 22 insertions(+) (limited to 'modules') diff --git a/modules/desktop/eww/workspaces.py b/modules/desktop/eww/workspaces.py index d8e774b..4019a17 100644 --- a/modules/desktop/eww/workspaces.py +++ b/modules/desktop/eww/workspaces.py @@ -59,15 +59,36 @@ def emit_workspaces(): workspaces = niri_json("workspaces") windows = {w["id"]: w for w in niri_json("windows")} + def window_sort_key(w): + # order windows as they appear in the columns; floating windows last + pos = (w.get("layout") or {}).get("pos_in_scrolling_layout") + if pos is not None: + return (0, pos[0], pos[1]) + return (1, w["id"], 0) + result = [] for ws in sorted(workspaces, key=lambda w: w["idx"]): active_win = windows.get(ws.get("active_window_id")) app_id = (active_win or {}).get("app_id") or "" + + ws_name = ws.get("name") or f"Workspace {ws['idx']}" + + ws_windows = sorted( + (w for w in windows.values() if w.get("workspace_id") == ws["id"]), + key=window_sort_key, + ) + lines = [ws_name] + [ + f"{i}. {(w.get('app_id') or 'unknown')}: {w.get('title') or '(untitled)'}" + for i, w in enumerate(ws_windows, start=1) + ] + tooltip = "\n".join(lines) if ws_windows else ws_name + result.append({ "idx": ws["idx"], "id": ws["id"], "is_active": ws.get("is_active", False), "icon": resolve_icon_path(app_id), + "tooltip": tooltip, }) print(json.dumps(result), flush=True) diff --git a/modules/desktop/eww/yuck.nix b/modules/desktop/eww/yuck.nix index 6f33ee1..6a7cbf4 100644 --- a/modules/desktop/eww/yuck.nix +++ b/modules/desktop/eww/yuck.nix @@ -126,6 +126,7 @@ (for ws in workspaces (eventbox :onclick "niri msg action focus-workspace ''${ws.idx}" :cursor "pointer" :halign "fill" + :tooltip "''${ws.tooltip}" (box :class "workspace-button ''${ws.is_active ? 'active' : '''}" :halign "fill" (overlay :halign "fill" (image :class "workspace-icon" -- cgit v1.2.3