Search code examples
bashubuntuwmctrl

(Xubuntu) How to display spinner animation in window title?


Using bash, I have been trying to add and display a simple spinner animation in the window decoration xfwm4 (next to the title of the window) of the Nemo (3.8.6) file manager. I’m using Xubuntu 18.04.2 LTS with the base Greybird theme.

Here is what I have tried. I installed the script found at this address:

https://askubuntu.com/questions/634034/display-the-current-date-time-in-the-windows-title/634158#634158

Works perfectly. This is what I obtained:

https://forum.ubuntu-fr.org/viewtopic.php?pid=22115889#p22115889

https://www.zupimages.net/up/19/26/owfa.png

On this screenshot, I would like to display the spinner next to the clock. I then tried to incorporate a simple spinner to the above script. I used this:

while :; do
  for c in / - \\ \|; do
    printf '%s\b' "$c"
    sleep .1
  done
done

The window decoration script:

while true
do
    wmctrl -r :ACTIVE: -N "$(awk -F' \\|\\|' '{print $1}' <<< $(xdotool getwindowfocus getwindowname)) || $(LANG=fr_FR.UTF-8 date "+%A %d %B %Y  -  %H:%M:%S")"
    sleep 1
done

This script properly displays a spinner in a console but:

  • never in the title of a window
  • the spinner is displayed within an insert cursor (how to remove this so only the spinner remains?)

Thanks for your time and help!


Solution

  • Reaplce

    printf '%s\b' "$c"
    

    with

    wmctrl -r :ACTIVE: -N $(printf '%s\b' "$c")
    

    Update:

    #!/bin/bash
    
    while :; do
      d=$(LANG=fr_FR.UTF-8 date "+%A %d %B %Y  -  %H:%M:%S")
      for c in / - \\ \|; do
        wmctrl -r :ACTIVE: -N "$c $d"
        sleep .1
      done
    done