Skip to content

Instantly share code, notes, and snippets.

@benny-sun
Created October 15, 2019 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benny-sun/364da1e4615cf273d838b6f6988bdaf8 to your computer and use it in GitHub Desktop.
Save benny-sun/364da1e4615cf273d838b6f6988bdaf8 to your computer and use it in GitHub Desktop.
Chrome remote desktop to the same display session. Chrome遠端桌面連線操作相同桌面(Session)
diff --git a/chrome-remote-desktop b/chrome-remote-desktop
index 3d78cd5..c936c0f 100755
--- a/chrome-remote-desktop
+++ b/chrome-remote-desktop
@@ -75,7 +75,7 @@ XORG_DUMMY_VIDEO_RAM = 1048576 # KiB
# with large or multiple monitors. This is a comma-separated list of
# resolutions that will be made available if the X server supports RANDR. These
# defaults can be overridden in ~/.profile.
-DEFAULT_SIZES = "1600x1200,3840x2560"
+DEFAULT_SIZES = "1920x1080"
# Xorg's dummy driver only supports switching between preconfigured sizes. To
# make resize-to-fit somewhat useful, include several common resolutions by
@@ -105,7 +105,7 @@ SESSION_FILE_PATH = os.path.join(HOME_DIR, ".chrome-remote-desktop-session")
SYSTEM_SESSION_FILE_PATH = "/etc/chrome-remote-desktop-session"
X_LOCK_FILE_TEMPLATE = "/tmp/.X%d-lock"
-FIRST_X_DISPLAY_NUMBER = 20
+FIRST_X_DISPLAY_NUMBER = 0
# Amount of time to wait between relaunching processes.
SHORT_BACKOFF_TIME = 5
@@ -422,8 +422,6 @@ class Desktop:
"""Return a candidate display number for which there is currently no
X Server lock file"""
display = FIRST_X_DISPLAY_NUMBER
- while os.path.exists(X_LOCK_FILE_TEMPLATE % display):
- display += 1
return display
def _init_child_env(self):
@@ -530,18 +528,6 @@ class Desktop:
max_width = max([width for width, height in self.sizes])
max_height = max([height for width, height in self.sizes])
- logging.info("Starting Xvfb on display :%d" % display)
- screen_option = "%dx%dx24" % (max_width, max_height)
- self.x_proc = subprocess.Popen(
- ["Xvfb", ":%d" % display,
- "-auth", x_auth_file,
- "-nolisten", "tcp",
- "-noreset",
- "-screen", "0", screen_option
- ] + extra_x_args, env=self._x_env())
- if not self.x_proc.pid:
- raise Exception("Could not start Xvfb.")
-
self._wait_for_x()
with open(os.devnull, "r+") as devnull:
@@ -705,8 +691,8 @@ class Desktop:
self._init_child_env()
self._setup_pulseaudio()
self._setup_gnubby()
- self._launch_x_server(x_args)
- self._launch_x_session()
+ display = self.get_unused_display_number()
+ self.child_env["DISPLAY"] = ":%d" % display
def launch_host(self, host_config, extra_start_host_args):
# Start remoting host
@benny-sun
Copy link
Author

Operation system: KDE neon 5.16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment