#!/bin/bash
trunc=16
sample=$(niri msg -j focused-window 2>/dev/null | jq -r '.title // ""' 2>/dev/null)

if [ ${#sample} -gt $trunc ]; then
    echo "$sample" | head -c $trunc | sed 's/$/…/'
else
    if [ ${#sample} -ne 0 ]; then
        echo "$sample"
    else
        echo "None"
    fi
fi
