26 lines
861 B
Bash
Executable File
26 lines
861 B
Bash
Executable File
#!/bin/bash
|
|
# Max character count before the title is truncated with an ellipsis.
|
|
trunc=16
|
|
# Query Hyprland over IPC for the active window and extract the title field.
|
|
# hyprctl outputs plain text; grep + awk picks the value after "title: ".
|
|
sample=$(hyprctl activewindow | grep title: | awk -F: '{print $2}')
|
|
|
|
#echo ${sample}
|
|
|
|
# ${#sample} is the string length. Truncate with head -c (byte cut) and append
|
|
# the UTF-8 ellipsis character "…" via sed's end-of-line anchor.
|
|
if [ ${#sample} -gt $trunc ]; then
|
|
echo $sample | head -c $trunc | sed 's/$/…/'
|
|
else
|
|
# If the title is non-empty but short enough, print as-is; otherwise "None"
|
|
# for Eww widgets that always need a non-empty string.
|
|
if [ ${#sample} -ne 0 ]; then
|
|
echo $sample
|
|
else
|
|
echo None
|
|
fi
|
|
fi
|
|
|
|
#hyprctl activewindow | grep title: | awk -F: '{print $2}' | head -c $trunc | sed 's/$/.../'
|
|
|