Guide for Ubuntu Desktop 24.04 with working snap apps and GNOME session - neutrinolabs/xrdp GitHub Wiki

Introduction

I have been researching for few days how to make GNOME start correctly, show Desktop icons for files/dirs and how to make Snap Firefox working out of the box (and other snap apps like snap-store)

This works for me on Ubuntu Desktop 24.04 LTS

Here what i found.

/etc/xrdp/startwm.sh

Add:

export DESKTOP_SESSION=ubuntu
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME

Add after the published under The MirOS Licence.
This will help you to start GNOME

Add:

unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR

Add before test -x /etc/X11/Xsession && exec /etc/X11/Xsession.
Those settings will help to start session and not crashing it after connection

~/.xsession

Just add the gnome-session to file. This option tells to start GNOME for the session

~/.xsessionrc

export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg

This settings will help to start correct desktop. Without those you will have Desktop with no files or dirs displayed, only in file manager. (even Home folder)

# waiting for socket if session starts slow
for i in {1..5}; do
    if [ -S "/run/user/$(id -u)/bus" ]; then
        break
    fi
    sleep 0.5
done

# export env only if socket really exists
if [ -S "/run/user/$(id -u)/bus" ]; then
    export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus"
    # inject this env to apps that you opened from menu/dock etc
    systemctl --user set-environment DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS
fi

Main part, how to get working snap apps like snap-store, firefox, etc.
We are waiting for socket to start.
Then export DBUS_SESSION_BUS_ADDRESS envirnoment and use systemctl --user set-environment to inject this env to apps that we start from menu/dock.
Default DBUS_SESSION_BUS_ADDRESS is binded to temp folder so snap apps not working and raises exception that session not in correct cgroup

gnome-system-monitor

Add

fs.inotify.max_user_instances=512
fs.inotify.max_user_watches=524288

Add to and of the file /etc/sysctl.conf
Apply settings by sudo sysctl -p for current session.

Bonus

Here some settings that i applied for /etc/xrdp/xrdp.ini

[Global]

tcp_send_buffer_bytes=4194304 - smoother rdp
crypt_level=none - NOT RECOMENDENDED IF YOU ARE NOT IN CLOSED NETWORK. THIS IS SECURITY RISK. smoother rdp
max_bpp=16 - less-color depth - smoother rdp

For search results

gnome-system-monitor
libEGL warning: DRI3 error: Could not get DRI3 device
libEGL warning: Ensure your X server supports DRI3 to get accelerated rendering
unhandled exception (type Glib::Error) in signal handler:
Unable to find default local file monitor type
/user.slice/user-1000.slice/session-c20.scope is not a snap cgroup for tag snap.firefox.firefox
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus"
empty desktop
no icons on desktop