A guide and automated script to configure Chrome Remote Desktop on Ubuntu to reuse your existing X session instead of launching a new virtual desktop.
By default, Chrome Remote Desktop creates a new virtual X session, which means you get a separate desktop environment that's isolated from your physical display. This can be problematic if you want to:
- Access the same desktop you see on your physical monitor
- Share your existing session with all your open applications
- Avoid the overhead of running a separate X server
This configuration modifies Chrome Remote Desktop to reuse your existing X session, allowing you to access your current desktop remotely.
- Ubuntu (tested on Ubuntu 17.10, 18.04, 20.04, 22.04, and later)
- Google Chrome browser installed
- Chrome Remote Desktop extension installed
- Visit Chrome Remote Desktop in your Chrome browser
- Follow the installation instructions provided on that page
- The installation will download and set up Chrome Remote Desktop on your system
- Open Chrome and go to Chrome Remote Desktop
- Click the "Turn on" button
- Name your device and set a PIN
Use the provided script to automatically configure Chrome Remote Desktop:
sudo ./configure-chrome-remote-desktop.shThe script will:
- Stop Chrome Remote Desktop if it's running
- Create a backup of the original configuration file
- Detect your current DISPLAY number
- Configure the resolution (default: 1920x1080, you can customize it)
- Modify the Chrome Remote Desktop configuration file
- Preserve file permissions
- Automatically restart Chrome Remote Desktop at the end
If you prefer to configure manually:
-
Stop Chrome Remote Desktop:
/opt/google/chrome-remote-desktop/chrome-remote-desktop --stop
-
Edit the configuration file:
sudo nano /opt/google/chrome-remote-desktop/chrome-remote-desktop
-
Find and modify
DEFAULT_SIZES:DEFAULT_SIZES = "1920x1080" # Change to your desired resolution
-
Set the X display number: First, check your current display:
echo $DISPLAY
Then set
FIRST_X_DISPLAY_NUMBERto match (usually 0 or 1):FIRST_X_DISPLAY_NUMBER = 0 # or 1, depending on your system
-
Comment out the display search loop: Find this section and comment it out:
#while os.path.exists(X_LOCK_FILE_TEMPLATE % display): # display += 1
-
Modify
launch_session()function: In theXDesktopclass, find thelaunch_session()method and replace it with:def launch_session(self, *args, **kwargs): self._init_child_env() self._setup_gnubby() #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() #self.server_inhibitor.record_started(MINIMUM_PROCESS_LIFETIME, # backoff_time) #self.session_inhibitor.record_started(MINIMUM_PROCESS_LIFETIME, # backoff_time) display = self.get_unused_display_number() self.child_env["DISPLAY"] = ":%d" % display
-
Save and exit the editor
-
Start Chrome Remote Desktop:
/opt/google/chrome-remote-desktop/chrome-remote-desktop --start
After configuration:
- Go to Chrome Remote Desktop in your Chrome browser
- Click on your device name
- Enter your PIN
- You should now see your existing desktop session, not a new virtual one
If you're unsure about your display number:
- Ubuntu 17.10 and lower: Usually
0 - Ubuntu 18.04: Usually
1 - Ubuntu 20.04+: Can be
0or1depending on your setup
Check with:
echo $DISPLAYThe number after the colon (:) is your display number.
-
Check if it's already running:
ps aux | grep chrome-remote-desktop -
Stop it if needed:
/opt/google/chrome-remote-desktop/chrome-remote-desktop --stop
-
Check the logs:
cat ~/.config/chrome-remote-desktop/chrome_remote_desktop_*.log
If the resolution doesn't match your screen:
- Edit the configuration file
- Change
DEFAULT_SIZESto match your screen resolution - Restart Chrome Remote Desktop
If you need to revert to the default behavior, the script automatically creates a backup of the original configuration file before making any changes. The backup is saved with a timestamp in the filename.
To restore from the backup:
-
Stop Chrome Remote Desktop:
/opt/google/chrome-remote-desktop/chrome-remote-desktop --stop
-
Find your backup file (it will be in
/opt/google/chrome-remote-desktop/with a name likechrome-remote-desktop.backup.YYYYMMDD_HHMMSS) -
Restore the backup:
sudo cp /opt/google/chrome-remote-desktop/chrome-remote-desktop.backup.YYYYMMDD_HHMMSS /opt/google/chrome-remote-desktop/chrome-remote-desktop
-
Start Chrome Remote Desktop:
sudo /opt/google/chrome-remote-desktop/chrome-remote-desktop --start
Alternatively, you can reinstall Chrome Remote Desktop, which will restore the original configuration file.
This configuration modifies system files. Use at your own risk. Always backup your configuration before making changes.
This configuration is based on community solutions for making Chrome Remote Desktop work with existing X sessions on Ubuntu.