2008-10-31 00:22:44 -04:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2008-11-01 19:55:49 -04:00
|
|
|
import os
|
2008-10-31 00:22:44 -04:00
|
|
|
import random
|
|
|
|
import shutil
|
2008-11-01 19:55:49 -04:00
|
|
|
import signal
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2008-10-31 00:22:44 -04:00
|
|
|
import tempfile
|
|
|
|
import time
|
|
|
|
|
2008-11-01 19:55:49 -04:00
|
|
|
from launcher import Launcher
|
2008-10-31 00:22:44 -04:00
|
|
|
|
2008-11-01 19:55:49 -04:00
|
|
|
launcher = Launcher()
|
|
|
|
|
|
|
|
# GL_EXT_texture_from_pixmap doesn't work in Xepyhr
|
|
|
|
launcher.set_use_tfp(False)
|
|
|
|
|
|
|
|
# Temporary directory to hold our X credentials
|
2008-10-31 00:22:44 -04:00
|
|
|
tmpdir = tempfile.mkdtemp("", "gnome-shell.")
|
|
|
|
try:
|
|
|
|
display = ":" + str(random.randint(10, 99))
|
|
|
|
xauth_file = os.path.join(tmpdir, "database")
|
|
|
|
|
|
|
|
# Create a random 128-byte key and format it as hex
|
|
|
|
f = open("/dev/urandom", "r")
|
|
|
|
key = f.read(16)
|
|
|
|
f.close()
|
|
|
|
hexkey = "".join(("%02x" % ord(byte) for byte in key))
|
|
|
|
|
|
|
|
# Store that in an xauthority file as the key for connecting to our Xephyr
|
2008-11-03 16:39:41 -05:00
|
|
|
retcode = subprocess.call(["xauth",
|
|
|
|
"-f", xauth_file,
|
|
|
|
"add", display, "MIT-MAGIC-COOKIE-1", hexkey])
|
2008-10-31 00:22:44 -04:00
|
|
|
if retcode != 0:
|
|
|
|
raise RuntimeError("xauth failed")
|
|
|
|
|
|
|
|
# Launch Xephyr
|
2008-11-03 16:39:41 -05:00
|
|
|
xephyr = subprocess.Popen(["Xephyr", display,
|
|
|
|
"-auth", xauth_file,
|
2008-11-19 16:15:59 -05:00
|
|
|
"-screen", "1024x748",
|
2008-11-03 16:39:41 -05:00
|
|
|
"-host-cursor"])
|
2008-10-31 00:22:44 -04:00
|
|
|
os.environ['DISPLAY'] = display
|
2008-11-03 16:39:41 -05:00
|
|
|
os.environ['XAUTHORITY'] = xauth_file
|
2008-10-31 00:22:44 -04:00
|
|
|
|
|
|
|
# Wait for server to get going: LAME
|
|
|
|
time.sleep(1)
|
|
|
|
|
2008-11-06 12:44:01 -05:00
|
|
|
# Start some windows in our session. Specify explicit geometries
|
|
|
|
# so we don't end up with the title bars underneath the panel
|
|
|
|
subprocess.Popen(["xterm", "-geometry", "+30+30"])
|
|
|
|
subprocess.Popen(["xlogo", "-geometry", "-0-0"])
|
|
|
|
subprocess.Popen(["xeyes", "-geometry", "-0+30"])
|
2008-10-31 00:22:44 -04:00
|
|
|
|
|
|
|
# Now launch metacity-clutter with our plugin
|
2008-11-01 19:55:49 -04:00
|
|
|
shell = launcher.start_shell()
|
|
|
|
|
2008-10-31 00:22:44 -04:00
|
|
|
# Wait for Xephyr to exit
|
|
|
|
try:
|
|
|
|
retcode = xephyr.wait()
|
|
|
|
except KeyboardInterrupt, e:
|
|
|
|
os.kill(xephyr.pid, signal.SIGKILL)
|
|
|
|
finally:
|
|
|
|
shutil.rmtree(tmpdir)
|
|
|
|
|