0

I have written a bash script that creates 10 terminals, then parses a file and writes a command randomly on one of the terminals. However, xdotool seems to freeze my entire ubuntu window exept for the mouse. I have to press alt+ctrl+f1 and restart Ubuntu to "unfreeze" it.

The script is the following:

#!/bin/bash
printf "$FBOLD\nPlease enter the port:  $FREG"
read invalue
for i in {1..9}; do
    xterm -title "node$i" -hold -e "node index.js localhost:${invalue}" &
    sleep 1
done

filename='insert.txt'
while read line; do
    # reading each line
    #sleep 1
    R=$((1 + $RANDOM % 10))
    echo "$R"

    # set focus on xterm with title `node...`
    xdotool windowfocus --sync $(xdotool search --name "node$R") 
    xdotool type "insert $line"
    xdotool key Return

    # xdotool key Return
done < $filename

What could be causing the freeze?

Socowi
  • 25,550
  • 3
  • 32
  • 54
  • Your script was very unwieldy. I shortened it for you to attract more users. The new script should be equivalent (including possible bugs). Nevertheless, please run it again and see if the problem still occurs. – Socowi Jan 02 '21 at 15:34
  • 1
    You only open 9 windows (node1-9) but try to access 10 windows (node1-10). Could the missing `node10` window be the problem? – Socowi Jan 02 '21 at 15:37
  • @Socowi Thank you, it runs like it did before! But the bug still remains ( I added a window called node10) Still freezes – asimplecoder Jan 02 '21 at 15:49
  • https://stackoverflow.com/questions/48038038/xdotool-type-takes-ages-and-causes-entire-desktop-to-freeze – Beast Winterwolf Feb 02 '21 at 01:21

0 Answers0