eww: Trim title of focused window

This commit is contained in:
Erwin Boskma 2024-04-03 17:22:52 +02:00
parent 380909e5f9
commit 5ad22d8d7d
Signed by: erwin
SSH key fingerprint: SHA256:/Wk1WZdLg+vQHs3in9qq7PsIp8SMzwGSk/RLZ5zPuZk

View file

@ -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 [] {