bash: 在活动 window 标题中显示简单的正弦曲线动画

bash: display simple sinusoid animation in active window title

我正在使用带有基本 Greybird 主题的 Xubuntu 18.04.2 LTS。我的文件管理器是 Nemo (3.8.6),window 装饰管理器是 xfwm4.

感谢这个 bash 脚本 1(下面的代码和此处的源代码 https://forum.ubuntu-fr.org/viewtopic.php?pid=22123363#p22123363),我可以在控制台上显示一个简单的正弦曲线 window。此动画还会在 window:

调整大小时自动调整

[脚本 1]

#!/bin/bash

motif="⠁⠂⠄⡀⢀⠠⠐⠈ "
tempo=0.04

recalcule() {
    columns=$( tput cols )
    repet=$(( columns / longMotif ))
    reste=$(( columns % longMotif ))
}

affPointApoint() {
    longChaine=${#1}
    for (( i=0; i<$longChaine; i++ )); do
        printf "${1:$i:1}"
        trap 'recalcule' SIGWINCH
    sleep $tempo
    done
}

longMotif="${#motif}"

while :; do
    recalcule
    tput clear   
    for (( x=0; x<$repet; x++ )); do
        affPointApoint "$motif"
    done
    affPointApoint "${motif:0:$reste}"
done

我现在想在控制台以外的 window 上显示这个简单的正弦曲线。甚至可以在活动 window 的装饰中执行此操作,例如在 window 标题旁边?

我的第一个想法是将 wmctrl 与下面的 script2 一起使用,但我没能做到。你觉得你能帮忙吗?谢谢!

[脚本 2]

#!/bin/bash
while true
do
  wmctrl -r :ACTIVE: -N "$(awk -F' \|\|' '{print }' <<<  $(xdotool  getwindowfocus getwindowname)) || $(sinusoid variable here)"
    sleep .1
done

感谢您的宝贵时间和帮助!

以下实际有效(从终端开始,将鼠标悬停在其他 windows 上);我希望这就是您所想的:

#!/bin/bash

motif="⠁⠂⠄⡀⢀⠠⠐⠈ "
tempo=0.04
len=${#motif}

i=0
while true
do
    left=${motif:0:i}
    right=${motif:i:len}

    wmctrl -r :ACTIVE: -N "${right}${left}"

    i=$((i+1))
    [ $i -eq $len ] && i=0

    sleep 0.1
done