Skip to content

Instantly share code, notes, and snippets.

@charterchap
Created March 13, 2015 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charterchap/b571104dc6c27547e443 to your computer and use it in GitHub Desktop.
Save charterchap/b571104dc6c27547e443 to your computer and use it in GitHub Desktop.
# I had a problem today where trying to load things into an Xvfb was not working because the xvfb
# was not yet initialized. The problem script is as follows:
# Start the Xvfb on DISPLAY :1,
`dirname $0`/Xvfb :1 -screen 0 1280x1024x24 -ac -br -fbdir /dev/shm & xvfbpid=$!
DISPLAY=:1 xli -onroot -fillscreen `dirname $0`/images/background.png
# The only solution I see on the web is to insert a sleep statement.
# I don't much like that. The solution I came up with is to wait for the display to be ready to use via xdpyinfo.
# The working script:
# Start the Xvfb on DISPLAY :1,
`dirname $0`/Xvfb :1 -screen 0 1280x1024x24 -ac -br -fbdir /dev/shm & xvfbpid=$!
# Wait for Xvfb to initialize
ACTIVE=9999
while [ $ACTIVE -ne 0 ] ; do
xdpyinfo -display :1 &> /dev/null
ACTIVE=$?
done
DISPLAY=:1 xli -onroot -fillscreen `dirname $0`/images/background.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment