#!/bin/sh
# Run XFree86 with the stable version of the proprietary AMD/ATI Linux
# drivers; necessary to properly initialize some ATI card variants.
#
# Unfortunately -probeonly doesn't seem to be sufficient, so we
# need to actually start the server, and then send SIGTERM to cause
# the server to quit.

# We could just use the existing XF86Config and explicitly specify
#    -modulepaths "@SHAREDIR@/,..."
# but figuring out the other paths seems difficult.  And this way
# we control what other extensions are loaded.
XF86CONFIG="@SHAREDIR@/XF86Config.initati"

if [ ! -f "${XF86CONFIG}" ]; then
    echo "error: ${XF86CONFIG} does not exist" 1>&2
    exit 1
fi
XFree86 -xf86config "${XF86CONFIG}" \
    -nolisten tcp -nolisten inet6 \
    "$@" &

pid=$!
sleep 5
kill $pid
wait $pid	# ensures lock file was removed

# this was necessary once or twice
if [ -t 1 ]; then
    stty sane
fi
