Automation using xdotool and Xvfb
I'm trying to automate getting CPU sampler data from visualvm on production system. But to do this I need a way to automate tasks inside Xvfb.
I found that xdotool is good for such automation. Right now I have following script:
Xvfb $DISPLAY -pixdepths 32 -screen 0 1280x1024x24 >/dev/null 2>&1 & XPID=$!开发者_运维问答
echo "Before twm"
#twm -display $DISPLAY &
gnome-wm &
#$VISUALVM --openpid $PID_TO_OPEN &
echo "Before gimp"
gimp &
sleep 5
xdotool search "GNU.*" windowactivate windowfocus key alt+f n
sleep 3
DISPLAY=:0.0
xwd -display :9.0 -root | xwdtopnm | pnmtopng > out.png
qiv out.png
It should open Xvfb, run gimp, and click File->New. It does that when I do it in normal X, but when I execute this script in Xvfb it looks like it doesn't pass keyboard events. I tested it with mouse and it's the same, xdotool doesn't pass (or Xvfb doesn't accept) events from mouse.
Has anyone encoundered this problem and know a solution?
精彩评论