Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add option to use existing Xorg session for chrome-remote-desktop
--- old/chrome-remote-desktop 2020-03-22 14:45:08.004042619 +0000
+++ new/chrome-remote-desktop 2020-03-22 14:46:38.627694296 +0000
@@ -106,6 +106,8 @@
X_LOCK_FILE_TEMPLATE = "/tmp/.X%d-lock"
FIRST_X_DISPLAY_NUMBER = 20
+EXISTING_X_DISPLAY_FILE_PATH = os.path.join(CONFIG_DIR, "Xsession")
+X_SESSION_FILE_TEMPLATE = "/tmp/.X11-unix/X%d"
# Amount of time to wait between relaunching processes.
SHORT_BACKOFF_TIME = 5
@@ -697,12 +699,25 @@
if not self.session_proc.pid:
raise Exception("Could not start X session")
+ def _use_existing_session(self):
+ with open(EXISTING_X_DISPLAY_FILE_PATH) as fh:
+ display = int(fh.readline().rstrip())
+ if not os.path.exists(X_SESSION_FILE_TEMPLATE % display):
+ logging.error("Xorg session file doesn't exist")
+ sys.exit(1)
+ logging.info("Using existing Xorg session: %d" % display)
+ self.child_env["DISPLAY"] = ":%d" % display
+ self.child_env["CHROME_REMOTE_DESKTOP_SESSION"] = "1"
+
def launch_session(self, x_args):
self._init_child_env()
self._setup_pulseaudio()
self._setup_gnubby()
- self._launch_x_server(x_args)
- self._launch_x_session()
+ if os.path.exists(EXISTING_X_DISPLAY_FILE_PATH):
+ self._use_existing_session()
+ else:
+ self._launch_x_server(x_args)
+ self._launch_x_session()
def launch_host(self, host_config, extra_start_host_args):
# Start remoting host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.