flakes/res/eww-wayland/scripts/title.sh

18 lines
508 B
Bash
Raw Normal View History

2024-01-17 15:33:46 +07:00
#!/usr/bin/env sh
out () {
if [ -z "$1" ]; then
echo ""
else
echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"$1\"))"
fi
}
init=$(hyprctl activewindow -j | jq --raw-output .title)
out "$init"
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}' | while read -r line ; do
trunc=$(echo $line | cut -c-85)
out "$trunc"
done