gnome-shell/scripts/start-in-Xephyr
Owen Taylor e81ed61a38 Add --debug and --verbose options to launcher scripts
Factor out a common Launcher class from start-in-Xepyhr and
start-replace that handles option parsing and launching gnome-shell,
and add options:

 -v/--verbose: Unless specified, suppress most gjs debug output
 -g/--debug: If specified run under gdb
 --debug-command: Run under some other debugging (strace/valgrind/etc.)
     Implies -g

svn path=/trunk/; revision=18
2008-11-01 23:55:49 +00:00

58 lines
1.5 KiB
Python
Executable File

#!/usr/bin/python
import os
import random
import shutil
import signal
import subprocess
import sys
import tempfile
import time
from launcher import Launcher
launcher = Launcher()
# GL_EXT_texture_from_pixmap doesn't work in Xepyhr
launcher.set_use_tfp(False)
# Temporary directory to hold our X credentials
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"])
# Now launch metacity-clutter with our plugin
shell = launcher.start_shell()
# Wait for Xephyr to exit
try:
retcode = xephyr.wait()
except KeyboardInterrupt, e:
os.kill(xephyr.pid, signal.SIGKILL)
finally:
shutil.rmtree(tmpdir)