1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
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!"
device = None
mouseProtocol = None
(mouseDev, driver, descr) = mice[0]
if mouseDev == 'psaux':
mouseProtocol = "PS/2"
mouseEmulate = 0
else:
mouseProtocol = "Microsoft"
mouseEmulate = 1
x = XF86Config ((mouseProtocol, mouseEmulate, mouseDev))
x.probe ()
if x.server:
serverPath = '/usr/X11R6/bin/XF86_' + x.server
else:
print "Unknown card, falling back to VGA16"
serverPath = '/usr/X11R6/bin/XF86_VGA16'
if not os.access (serverPath, os.X_OK):
print serverpath, "missing. Falling back to VGA16"
serverPath = '/usr/X11R6/bin/XF86_VGA16'
settings = { "mouseDev" : '/dev/' + mouseDev ,
"mouseProto" : mouseProtocol }
f = open ('/tmp/XF86Config', 'w')
f.write ("""
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
EndSection
Section "ServerFlags"
EndSection
Section "Keyboard"
Protocol "Standard"
AutoRepeat 500 5
LeftAlt Meta
RightAlt Meta
ScrollLock Compose
RightCtl Control
XkbKeymap "xfree86(us)"
XkbKeycodes "xfree86"
XkbTypes "default"
XkbCompat "default"
XkbSymbols "us(pc101)"
XkbGeometry "pc"
XkbRules "xfree86"
XkbModel "pc101"
XkbLayout "us"
EndSection
Section "Pointer"
Protocol "%(mouseProto)s"
Device "%(mouseDev)s"
Emulate3Buttons
Emulate3Timeout 50
EndSection
""" % settings)
f.write (x.monitorSection ())
f.write (x.deviceSection ())
x.modes["8"] = [ "640x480" ]
x.modes["16"] = [ "640x480" ]
x.modes["32"] = [ "640x480" ]
f.write (x.screenSection ())
f.close ()
server = os.fork()
if (not server):
print "starting", serverPath
os.execv(serverPath, [serverPath, ':1', '-xf86config',
'/tmp/XF86Config', 'vt7'])
# 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)
return ((mouseProtocol, mouseEmulate, mouseDev), x)
|