Signed-off-by: Jeremy White <jwhite@xxxxxxxxxxxxxxx> --- scripts/Xspice | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/scripts/Xspice b/scripts/Xspice index d7b3887..9917aca 100755 --- a/scripts/Xspice +++ b/scripts/Xspice @@ -20,6 +20,7 @@ import argparse import os import sys import tempfile +import time def which(x): for p in os.environ['PATH'].split(':'): @@ -46,6 +47,7 @@ parser = argparse.ArgumentParser("Xspice", epilog="Any options not parsed by Xspice get passed to Xorg as is.") parser.add_argument('--xorg', default=which('Xorg')) parser.add_argument('--auto', action='store_true', help='Automatically create a temporary xorg.conf and start the X server') +parser.add_argument('--xsession', help='If given, will run after Xorg launch. Should be a program like x-session-manager') parser.add_argument('--config', default='spiceqxl.xorg.conf') # Don't use any options that are already used by Xorg (unless we must) # specifically, don't use -p and -s. @@ -185,17 +187,33 @@ for arg in var_args: a = str(a) os.environ['XSPICE_' + arg.upper()] = a +display="" +for arg in xorg_args: + if arg.startswith(":"): + display = arg + exec_args = [args.xorg, '-config', args.config] if cgdb and args.cgdb: exec_args = [cgdb, '--args'] + exec_args args.xorg = cgdb xpid = os.spawnv(os.P_NOWAIT, args.xorg, exec_args + xorg_args) -try: - os.waitpid(xpid, 0) -except KeyboardInterrupt: -# Catch Ctrl-C so we clean up the log file in that case - print "Keyboard Interrupt" +time.sleep(2) + +retpid,rc = os.waitpid(xpid, os.WNOHANG) +if retpid != 0: + print "Error: X server is not running" +else: + if args.xsession: + environ = os.environ + environ ['DISPLAY'] = display + os.spawnlpe(os.P_NOWAIT, args.xsession, environ) + + try: + os.waitpid(xpid, 0) + except KeyboardInterrupt: + # Catch Ctrl-C so we clean up the log file in that case + print "Keyboard Interrupt" if args.auto: if os.path.isfile(cf.name + ".log"): -- 1.7.10.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel