diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 00:08:58 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 00:08:58 +0000 |
commit | 500140977306b77c4c2d7dc4c1e62a8a8735a1b7 (patch) | |
tree | 9c72e52cd271865e61b98ac4a0bd79644c08153c /remoting | |
parent | e5ec48bce8045b94071e105b12999dc863b72b63 (diff) | |
download | chromium_src-500140977306b77c4c2d7dc4c1e62a8a8735a1b7.zip chromium_src-500140977306b77c4c2d7dc4c1e62a8a8735a1b7.tar.gz chromium_src-500140977306b77c4c2d7dc4c1e62a8a8735a1b7.tar.bz2 |
Choose Virtual Me2Me X session based on installed components.
This updates the Virtual Me2Me script to work on Ubuntu 12.04 as well as Ubuntu
10.04.
BUG=131440
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/10690175
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147350 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rwxr-xr-x | remoting/tools/me2me_virtual_host.py | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/remoting/tools/me2me_virtual_host.py b/remoting/tools/me2me_virtual_host.py index fa6683e..e2b1849 100755 --- a/remoting/tools/me2me_virtual_host.py +++ b/remoting/tools/me2me_virtual_host.py @@ -33,6 +33,14 @@ import uuid import gaia_auth import keygen +# By default this script will try to determine the most appropriate X session +# command for the system. To use a specific session instead, set this variable +# to the executable filename, or a list containing the executable and any +# arguments, for example: +# XSESSION_COMMAND = "/usr/bin/gnome-session-fallback" +# XSESSION_COMMAND = ["/usr/bin/gnome-session", "--session=ubuntu-2d"] +XSESSION_COMMAND = None + REMOTING_COMMAND = "remoting_me2me_host" # Command-line switch for passing the config path to remoting_me2me_host. @@ -352,14 +360,13 @@ class Desktop: def launch_x_session(self): # Start desktop session - # The /dev/null input redirection is necessary to prevent Xsession from + # The /dev/null input redirection is necessary to prevent the X session # reading from stdin. If this code runs as a shell background job in a # terminal, any reading from stdin causes the job to be suspended. # Daemonization would solve this problem by separating the process from the # controlling terminal. - # - # This assumes that GDM is installed and configured on the system. - self.session_proc = subprocess.Popen("/etc/gdm/Xsession", + logging.info("Launching X session: %s" % XSESSION_COMMAND) + self.session_proc = subprocess.Popen(XSESSION_COMMAND, stdin=open(os.devnull, "r"), cwd=HOME_DIR, env=self.child_env) @@ -458,6 +465,38 @@ class PidFile: os.remove(self.filename) +def choose_x_session(): + """Chooses the most appropriate X session command for this system. + + If XSESSION_COMMAND is already set, its value is returned directly. + Otherwise, a session is chosen for this system. + + Returns: + A string containing the command to run, or a list of strings containing + the executable program and its arguments, which is suitable for passing as + the first parameter of subprocess.Popen(). If a suitable session cannot + be found, returns None. + """ + if XSESSION_COMMAND is not None: + return XSESSION_COMMAND + + # Unity-2d would normally be the preferred choice on Ubuntu 12.04. At the + # time of writing, this session does not work properly (missing launcher and + # panel), so gnome-session-fallback is used in preference. + # "unity-2d-panel" was chosen here simply because it appears in the TryExec + # line of the session's .desktop file; other choices might be just as good. + for test_file, command in [ + ("/usr/bin/gnome-session-fallback", "/usr/bin/gnome-session-fallback"), + ("/etc/gdm/Xsession", "/etc/gdm/Xsession"), + ("/usr/bin/unity-2d-panel", + ["/usr/bin/gnome-session", "--session=ubuntu-2d"]), + ]: + if os.path.exists(test_file): + return command + + return None + + def locate_executable(exe_name): for path in EXE_PATHS_TO_TRY: exe_path = os.path.join(SCRIPT_PATH, path, exe_name) @@ -618,6 +657,18 @@ def main(): sizes.append((width, height)) + global XSESSION_COMMAND + XSESSION_COMMAND = choose_x_session() + if XSESSION_COMMAND is None: + print >> sys.stderr, "Unable to choose suitable X session command." + return 1 + + if "--session=ubuntu-2d" in XSESSION_COMMAND: + print >> sys.stderr, ( + "The Unity 2D desktop session will be used.\n" + "If you encounter problems with this choice of desktop, please install\n" + "the gnome-session-fallback package, and restart this script.\n") + atexit.register(cleanup) for s in [signal.SIGHUP, signal.SIGINT, signal.SIGTERM, signal.SIGUSR1]: |