2008-10-31 04:22:44 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2008-11-01 23:55:49 +00:00
|
|
|
import os
|
2008-10-31 04:22:44 +00:00
|
|
|
import random
|
|
|
|
import shutil
|
2008-11-01 23:55:49 +00:00
|
|
|
import signal
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2008-10-31 04:22:44 +00:00
|
|
|
import tempfile
|
|
|
|
import time
|
|
|
|
|
2008-11-01 23:55:49 +00:00
|
|
|
from launcher import Launcher
|
2008-10-31 04:22:44 +00:00
|
|
|
|
2008-11-01 23:55:49 +00: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 04:22:44 +00: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
|
|
|
|
os.environ['XAUTHORITY'] = xauth_file
|
|
|
|
retcode = subprocess.call(["xauth", "add", display, "MIT-MAGIC-COOKIE-1", hexkey])
|
|
|
|
if retcode != 0:
|
|
|
|
raise RuntimeError("xauth failed")
|
|
|
|
|
|
|
|
# Launch Xephyr
|
|
|
|
xephyr = subprocess.Popen(["Xephyr", display, "-screen", "800x600", "-host-cursor"])
|
|
|
|
os.environ['DISPLAY'] = display
|
|
|
|
|
|
|
|
# Wait for server to get going: LAME
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
# Start xterm to have some window in our session
|
|
|
|
subprocess.Popen(["xterm"])
|
2008-11-02 04:18:38 +00:00
|
|
|
subprocess.Popen(["xlogo"])
|
|
|
|
subprocess.Popen(["xeyes"])
|
2008-10-31 04:22:44 +00:00
|
|
|
|
|
|
|
# Now launch metacity-clutter with our plugin
|
2008-11-01 23:55:49 +00:00
|
|
|
shell = launcher.start_shell()
|
|
|
|
|
2008-10-31 04:22:44 +00:00
|
|
|
# Wait for Xephyr to exit
|
|
|
|
try:
|
|
|
|
retcode = xephyr.wait()
|
|
|
|
except KeyboardInterrupt, e:
|
|
|
|
os.kill(xephyr.pid, signal.SIGKILL)
|
|
|
|
finally:
|
|
|
|
shutil.rmtree(tmpdir)
|
|
|
|
|