From 5ad22d8d7d132760ad7d67f12f8d047d11355fdd Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Wed, 3 Apr 2024 17:22:52 +0200 Subject: [PATCH] eww: Trim title of focused window --- home-manager/modules/eww/config/scripts/workspaces.nu | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/home-manager/modules/eww/config/scripts/workspaces.nu b/home-manager/modules/eww/config/scripts/workspaces.nu index 6f8c6be..b2cdc20 100755 --- a/home-manager/modules/eww/config/scripts/workspaces.nu +++ b/home-manager/modules/eww/config/scripts/workspaces.nu @@ -35,9 +35,14 @@ use ipc ipc-cmd def workspaces [] { let workspaces = (ipc-cmd "-t" "get_workspaces" | select id name focused urgent visible) let mode = (ipc-cmd "-t" "get_binding_state") - let focused_title = ((ipc-cmd --raw "-t" "get_tree") | jaq -r '.. | (.nodes? // empty)[] | select(.focused) | {name}' | from json) - - { workspaces: $workspaces, mode: $mode.name, title: $focused_title.name } + let focused_title_full = ((ipc-cmd --raw "-t" "get_tree") | jaq -r '.. | (.nodes? // empty)[] | select(.focused) | {name}' | from json).name + mut focused_title = ($focused_title_full | str substring -g 0..150) + + if ($focused_title_full | str length) > 150 { + $focused_title = ($focused_title | append "..." | str join "") + } + + { workspaces: $workspaces, mode: $mode.name, title: $focused_title } } def main [] {