Running GNOME on Ubuntu 24.04 LTS - matt335672/xrdp GitHub Wiki

Problem description

When attempting to use GNOME out-of-the-box over xrdp on Ubuntu 24.04 LTS, the following problems are encountered:-

  1. The session has a solid blue background rather than the default Ubuntu desktop background.
  2. Some X applications (i.e. gnome-terminal) take 30 seconds or so to start
  3. Messages relating to the IBus session server failing may be received
  4. Running systemctl --user status --state=failed in a terminal window shows the following problems:-
    × org.freedesktop.IBus.session.GNOME.service - IBus Daemon for GNOME
         Loaded: loaded (/usr/lib/systemd/user/org.freedesktop.IBus.session.GNOME.service; enabled; preset: enabled)
         Active: failed (Result: exit-code) since Tue 2024-04-30 10:21:52 BST; 2min 12s ago
        Process: 16825 ExecStart=sh -c exec /usr/bin/ibus-daemon --panel disable $([ "$XDG_SESSION_TYPE" = "x11" ] && echo "--xim") (code=exited, status=255/EXCEPTION)
       Main PID: 16825 (code=exited, status=255/EXCEPTION)
            CPU: 7ms
    
    Apr 30 10:21:52 ubuntu24 systemd[16366]: Starting org.freedesktop.IBus.session.GNOME.service - IBus Daemon for GNOME...
    Apr 30 10:21:52 ubuntu24 sh[16825]: current session already has an ibus-daemon.
    Apr 30 10:21:52 ubuntu24 systemd[16366]: org.freedesktop.IBus.session.GNOME.service: Main process exited, code=exited, status=255/EXCEPTION
    Apr 30 10:21:52 ubuntu24 systemd[16366]: org.freedesktop.IBus.session.GNOME.service: Failed with result 'exit-code'.
    Apr 30 10:21:52 ubuntu24 systemd[16366]: Failed to start org.freedesktop.IBus.session.GNOME.service - IBus Daemon for GNOME.
    
    × xdg-desktop-portal.service - Portal service
         Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal.service; static)
         Active: failed (Result: timeout) since Tue 2024-04-30 10:23:21 BST; 43s ago
        Process: 16640 ExecStart=/usr/libexec/xdg-desktop-portal (code=killed, signal=TERM)
       Main PID: 16640 (code=killed, signal=TERM)
            CPU: 68ms
    
    Apr 30 10:21:51 ubuntu24 systemd[16366]: Starting xdg-desktop-portal.service - Portal service...
    Apr 30 10:22:41 ubuntu24 xdg-desktop-por[16640]: Failed to create settings proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached
    Apr 30 10:23:06 ubuntu24 xdg-desktop-por[16640]: Failed to create file chooser proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gnome: Timeout was reached
    Apr 30 10:23:06 ubuntu24 xdg-desktop-por[16640]: No skeleton to export
    Apr 30 10:23:21 ubuntu24 systemd[16366]: xdg-desktop-portal.service: start operation timed out. Terminating.
    Apr 30 10:23:21 ubuntu24 systemd[16366]: xdg-desktop-portal.service: Failed with result 'timeout'.
    Apr 30 10:23:21 ubuntu24 systemd[16366]: Failed to start xdg-desktop-portal.service - Portal service.
    

Analysis

The generic X11 startup scripts used by xrdp to start a session are attempting to start a vanilla GNOME session rather than the customized Ubuntu GNOME session used on the desktop. This has been noted in the past - see #1723 and #2522.

This session type will not be tested before delivery in the same way as the Ubuntu GNOME session, as it cannot be selected from the normal graphical login screen.

Also note that the /etc/xrdp/startm.sh provided by the xrdp installation is customised by the Debian team rather than the Ubuntu team. The Ubuntu team make no further changes to this script for Ubuntu support.

Solution

The solution is to edit /etc/xrdp/startwm.sh on Ubuntu and run a GNOME Ubuntu session if GNOME is set as the default desktop.

Locate these lines at the end of /etc/xrdp/startwm.sh:-

test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession

Immediately BEFORE these lines, add these blocks:-

USERXSESSION=$HOME/.xsession
ALTUSERXSESSION=$HOME/.Xsession
ERRFILE=$HOME/.xsession-errors

using_gnome=
if [ -e "$USERXSESSION" ] || [ -e "$ALTUSERXSESSION" ]; then
	: # User has specified their own session

elif [ -e /usr/bin/x-session-manager ]; then
	case "$(readlink -f /usr/bin/x-session-manager)" in
		*/gnome-session) using_gnome=1
	esac
fi

if [ -n "$using_gnome" ]; then
# Use the Ubuntu-GNOME spin
	export DESKTOP_SESSION=ubuntu-xorg
	export XDG_SESSION_DESKTOP="$DESKTOP_SESSION"
	export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu-xorg:/etc/xdg
	export XDG_CURRENT_DESKTOP=ubuntu:GNOME
	export XDG_DATA_DIRS=/usr/share/"$DESKTOP_SESSION":/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
	export GNOME_SHELL_SESSION_MODE=ubuntu
	exec >"$ERRFILE" 2>&1
	exec /usr/bin/gnome-session --session=ubuntu
fi

The first of these blocks discovers whether GNOME is selected as the default desktop. If it is, the second block sets up the environment used by GDM (the GNOME login program), and then duplicated the Exec= line in /usr/share/xsessions/ubuntu-xorg.desktop.