Minimizing & raising a window from a shell script

windowx11xdotool

I am trying to run a script that will check internet speed on a linux machine with gui, bring the terminal window down and when the query is finished , the window will come up with the answer.
as for the time being- i can take the window down, but not up.

    #!/bin/bash
    xdotool getactivewindow windowminimize
    #xdotool set_window --name speedy
    #xdotool set_window --icon-name speedy
    speedtest-cli --simple

    if [ $? -eq 0 ]
    then
    #xdotool windowactivate speedy
    xdotool windowfocus  #speedy
    xdotool key "F11"
    fi

    exec $SHELL

Best Answer

xdotool needs to know the window ID for all its actions. You correctly used getactivewindow to obtain the window for the windowminimize command, but you also need to do it for setting its name. So put

xdotool getactivewindow set_window --name speedy

before the minimize line.

Then you can use search to find it for activating later.

xdotool search --name speedy windowactivate

See the manpage sections Window stack and Command chaining for an explanation of how this all works.

The whole script:

#!/bin/bash
# rename the window for finding it again later
xdotool getactivewindow set_window --name speedy
xdotool search --name speedy windowminimize

speedtest-cli --simple

if [ $? -eq 0 ]
then
  xdotool search --name speedy windowactivate
  xdotool key "F11"
fi