flakes/res/eww/scripts/title.sh

18 lines
508 B
Bash
Raw Normal View History

2022-03-22 23:50:53 +07:00
#!/usr/bin/env sh
2024-01-16 01:08:18 +07:00
out () {
if [ -z "$1" ]; then
2022-03-22 23:50:53 +07:00
echo ""
else
2024-01-16 01:08:18 +07:00
echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"$1\"))"
2022-03-22 23:50:53 +07:00
fi
2024-01-16 01:08:18 +07:00
}
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"
2022-03-22 23:50:53 +07:00
done