Skip to content

Instantly share code, notes, and snippets.

@heri16
Last active August 4, 2023 16:31
Show Gist options
  • Save heri16/c64ec7a20334cc4037ab879083bed5a4 to your computer and use it in GitHub Desktop.
Save heri16/c64ec7a20334cc4037ab879083bed5a4 to your computer and use it in GitHub Desktop.
Patch chrome-remote-desktop to use DISPLAY 0

Usage

curl -o- https://gist.githubusercontent.com/heri16/c64ec7a20334cc4037ab879083bed5a4/raw/chrome-remote-desktop.patch | sudo patch /opt/google/chrome-remote-desktop/chrome-remote-desktop
crd --restart
--- /opt/google/chrome-remote-desktop/chrome-remote-desktop 2020-07-20 13:48:59.000000000 +0800
+++ ./chrome-remote-desktop 2020-07-20 13:41:43.755333986 +0800
@@ -452,6 +452,17 @@
display += 1
return display
+ @staticmethod
+ def get_used_display_number():
+ """Return a candidate display number for which there is currently a
+ X Server lock file"""
+ display = 0
+ while not os.path.exists(X_LOCK_FILE_TEMPLATE % display):
+ display += 1
+ if display > 100:
+ return 0
+ return display
+
def _init_child_env(self):
self.child_env = dict(os.environ)
@@ -747,8 +758,13 @@
self._init_child_env()
self._setup_pulseaudio()
self._setup_gnubby()
- self._launch_x_server(x_args)
- self._launch_x_session()
+ display = self.get_used_display_number()
+ logging.info(display)
+ if display is not None:
+ self.child_env["DISPLAY"] = ":%d" % display
+ else:
+ self._launch_x_server(x_args)
+ self._launch_x_session()
def launch_host(self, host_config, extra_start_host_args):
# Start remoting host
@AndnixSH
Copy link

AndnixSH commented Apr 9, 2023

Can you update the script? The hunk #2 fails at 758

@endrik-exe
Copy link

Can you update the script? The hunk #2 fails at 758

https://gist.github.com/endrik-exe/69131bd787a3b4cdfd862f971aaa82bc

Here is updated version 2023

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