diff options
| author | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-28 04:01:22 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-29 03:50:31 +0530 |
| commit | ed6a42bcace45203385e0a1126fa1d72b1e64c29 (patch) | |
| tree | b4fa409a56241f6d574dc0834c786898af233392 /modules | |
| parent | ec0606538442fc10f9f57c67f235176f139a1408 (diff) | |
| download | home-manager-config-ed6a42bcace45203385e0a1126fa1d72b1e64c29.tar.gz home-manager-config-ed6a42bcace45203385e0a1126fa1d72b1e64c29.zip | |
desktop: showing tooltip on hover for workspace buttons
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/desktop/eww/workspaces.py | 21 | ||||
| -rw-r--r-- | modules/desktop/eww/yuck.nix | 1 |
2 files changed, 22 insertions, 0 deletions
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" |
