Singing Hatsune Miku
Ainyaku.com

How to install Chrome Remote Desktop on Ubuntu Linux without creating a new session

Important: This method of getting Chrome Remote Desktop to work on Ubuntu seems to no longer work from my experience. Instead, I recommend using DWService, a different browser based remote desktop software, that has many more features, works fine on Linux and Windows, and is completely free.

Introduction

When installing Chrome Remote Desktop on Ubuntu Linux the standard way, it will try to create a new session and show this message instead of showing you what is currently on the computer’s screen:

If you instead do not want to create a new session and only mirror what is currently on the computer’s screen, follow these steps.

Installation

Go to Chrome Remote Desktop’s website on Google Chrome and begin the steps to setup your computer for remote access. Once it downloads Chrome Remote Desktop, open terminal and run sudo apt-get install [path of downloaded file], replacing [path of downloaded file] with the path of the downloaded .deb file. Once this finishes, return back to Google Chrome and finish the setup steps.

Note: If there are any issues with Chrome Remote Desktop when following these steps, run sudo apt-get --purge remove chrome-remote-desktop to uninstall it and try again.

Now, try to connect to the computer using Chrome Remote Desktop on another device signed in with the same Google account. You should see a similar message to the one shown in the image below:

If you see this message, then everything is working as intended so far. You may now disconnect from the computer.

Modifying Chrome Remote Desktop to use the current session

Open the folder at /opt/google/chrome-remote-desktop/ and make 2 copies of the chrome-remote-desktop file in another folder. One copy will be a backup and one will be used for editing.

Open the copy you made for editing in a text editor, and find the line that says DEFAULT_SIZES. Change this to the resolution of your screen. Example: DEFAULT_SIZES = "1920x1080"

Note: I don’t recommend editing the file in a terminal text editor like Nano because the file is very large, so you may need to use Ctrl+F to find the lines you need to edit.

Now, open terminal and run echo $DISPLAY. Back in the chrome-remote-desktop file, find the line that says FIRST_X_DISPLAY_NUMBER and change it to the number returned by echo $DISPLAY. Example: FIRST_X_DISPLAY_NUMBER = 0

Next, find and comment out the lines that say:

while os.path.exists(X_LOCK_FILE_TEMPLATE % display):
    display += 1

Note: Commenting out lines is done by adding a # in front of the line.

Then, find the line that says def launch_session(self, server_args, backoff_time):. The code below this line defines the launch_session() function. Inside this function, comment out the lines:

self._launch_server(server_args)
if not self._launch_pre_session():
      # If there was no pre-session script, launch the session immediately.
      self.launch_desktop_session()

And add these lines after those:

display = self.get_unused_display_number()
self.child_env["DISPLAY"] = ":%d" % display

Finally, save the file and run these commands in the terminal, replacing [path of file you just edited] with the path of the chrome-remote-desktop file copy you just edited:

sudo /opt/google/chrome-remote-desktop/chrome-remote-desktop --stop
sudo cp [path of file you just edited] /opt/google/chrome-remote-desktop
sudo /opt/google/chrome-remote-desktop/chrome-remote-desktop --start

Note: You should not delete the edited copy of the file, because updating Chrome Remote Desktop may undo or break the edits made to the chrome-remote-desktop file. If this ever happens, you may be able to repeat the commands above to fix it as long as you kept the edited file.

To make sure this worked, connect to the computer again using Chrome Remote Desktop on another device signed in with the same Google account, and you should not see a message anymore about creating a new session. You should just see a mirror of what is currently on your screen, and be able to interact with it. If your computer shows as offline, restart the computer and check again.

Sources

All of the information in this tutorial comes from this outdated Superuser StackExtange post, and from my own experience with trying to get this solution to work on the latest version of Chrome Remote Desktop in 2023.

Last updated 8/23/2023