The link I posted had a hint to the bash coproc directive and that is what I used. Not before reading some condescending stuff about how coproc is useless compared to the complicated file descriptor stuff. It is remarkable that people that do this stuff from day to day would not have an open mind about when it should be used.
This fixes it.
Setup the coproc by running the program in the background:
Code:
coproc xinput test-xi2
Read the coproc any time you need to and will read all lines with '' but may not terminate until the 1 second delay specified:
Code:
read -d '' -t 1 XINPUT_OUTPUT <&"${COPROC[0]}"
Actually display the results if you want:
Code:
echo "Finally the output: $XINPUT_OUTPUT"