2014-08-30 14:45:08 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
XPID=
|
2016-01-05 10:46:43 -05:00
|
|
|
FPID=
|
2014-08-30 14:45:08 -04:00
|
|
|
function create_fake_x ( )
|
|
|
|
{
|
2014-08-30 14:53:35 -04:00
|
|
|
export DISPLAY=":$1"
|
2014-08-30 14:45:08 -04:00
|
|
|
echo "Starting fake X: ${DISPLAY}"
|
2017-05-27 18:43:46 -04:00
|
|
|
Xvfb +extension XINERAMA +xinerama -screen 0 1280x1024x24 -screen 1 800x600x24 ${DISPLAY} &>test-x-logs/xserver-:$1.log &
|
2014-08-30 14:45:08 -04:00
|
|
|
XPID=$!
|
2016-01-07 15:27:20 -05:00
|
|
|
sleep 1;
|
2017-05-30 09:07:48 -04:00
|
|
|
if [ -x "$(which fluxbox 2>/dev/null)" ]; then
|
|
|
|
timeout -k 30s 30s fluxbox &>test-x-logs/fluxbox-:$1.log &
|
|
|
|
FPID=$!
|
|
|
|
sleep 1
|
|
|
|
fi
|
2014-08-30 14:45:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function destroy_fake_x ( )
|
|
|
|
{
|
|
|
|
if [ -n "${XPID}" ]
|
|
|
|
then
|
2016-01-05 10:46:43 -05:00
|
|
|
echo "Stopping fake X: ${XPID} - ${FPID}"
|
2017-05-30 09:07:48 -04:00
|
|
|
if [ -n "${FPID}" ]; then
|
|
|
|
kill ${FPID}
|
|
|
|
echo " wait flux"
|
|
|
|
wait ${FPID}
|
|
|
|
fi
|
2014-08-30 14:45:08 -04:00
|
|
|
kill ${XPID}
|
2016-01-08 16:17:00 -05:00
|
|
|
echo "wait x"
|
2014-08-30 14:45:08 -04:00
|
|
|
wait ${XPID}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-05-27 18:43:46 -04:00
|
|
|
if [ -n "$3" ]
|
2014-08-30 14:45:08 -04:00
|
|
|
then
|
2014-08-30 14:53:35 -04:00
|
|
|
export PATH=$3:$PATH
|
2014-08-30 14:45:08 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
create_fake_x "$1"
|
2017-05-27 18:43:46 -04:00
|
|
|
"$2" "$4"
|
2014-08-30 14:45:08 -04:00
|
|
|
RES=$?
|
|
|
|
|
|
|
|
destroy_fake_x
|
|
|
|
|
|
|
|
exit ${RES}
|