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
|
2008-11-03 21:39:41 +00:00
|
|
|
retcode = subprocess.call(["xauth",
|
|
|
|
"-f", xauth_file,
|
|
|
|
"add", display, "MIT-MAGIC-COOKIE-1", hexkey])
|
2008-10-31 04:22:44 +00:00
|
|
|
if retcode != 0:
|
|
|
|
raise RuntimeError("xauth failed")
|
|
|
|
|
|
|
|
# Launch Xephyr
|
2008-11-03 21:39:41 +00:00
|
|
|
xephyr = subprocess.Popen(["Xephyr", display,
|
|
|
|
"-auth", xauth_file,
|
|
|
|
"-screen", "800x600",
|
|
|
|
"-host-cursor"])
|
2008-10-31 04:22:44 +00:00
|
|
|
os.environ['DISPLAY'] = display
|
2008-11-03 21:39:41 +00:00
|
|
|
os.environ['XAUTHORITY'] = xauth_file
|
2008-10-31 04:22:44 +00:00
|
|
|
|
|
|
|
# Wait for server to get going: LAME
|
|
|
|
time.sleep(1)
|
|
|
|
|
2008-11-06 17:44:01 +00: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 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)
|
|
|
|
|