I though that you were doing the experiments using a ssh shell from another computer...
To disable X from getting the events first, you have to send a SIGSTOP to the X server in the run.sh, and when you are done a SIGCONT.
ps -efa | grep Xfbdev | sed 's/ */ /g' | cut -d ' ' -f 2 | xargs kill -STOP
or something like that