import os
import string
import kudzu
import isys
import sys
import time
from xf86config import *
def startX():
global serverPath
global mode
os.environ['DISPLAY'] = ':1'
serverPath = None
print "Probing for mouse type..."
mice = kudzu.probe (kudzu.CLASS_MOUSE,
kudzu.BUS_UNSPEC,
kudzu.PROBE_ONE);
if not mice:
raise RuntimeError, "Unable to find a mouse!"
server = os.fork()
if (not server):
print "starting", serverPath
args = [serverPath, ':1', 'vt7', '-s', '1440']
if serverPath[0:19] == '/usr/X11R6/bin/Xsun':
try:
os.unlink("/dev/mouse")
except:
pass
os.symlink(mouseDev, "/dev/mouse")
if x.device:
args.append ("-dev")
args.append ('/dev/' + x.device)
else:
args.append("-xf86config")
args.append("/tmp/XF86Config")
os.execv(serverPath, args)
# give time for the server to fail (if it is going to fail...)
time.sleep (1)
pid, status = os.waitpid (server, os.WNOHANG)
if status:
raise RuntimeError, "X server failed to start"
child = os.fork()
if (child):
try:
pid, status = os.waitpid(child, 0)
except:
sys.exit (-1)
sys.exit((status >> 8) & 0xf)