Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems running GNOME on Ubuntu 24.04 LTS #3053

Open
matt335672 opened this issue Apr 30, 2024 · 20 comments
Open

Problems running GNOME on Ubuntu 24.04 LTS #3053

matt335672 opened this issue Apr 30, 2024 · 20 comments

Comments

@matt335672
Copy link
Member

xrdp version

0.9.24

Detailed xrdp version, build options

xrdp 0.9.24
  A Remote Desktop Protocol Server.
  Copyright (C) 2004-2020 Jay Sorg, Neutrino Labs, and all contributors.
  See https://github.com/neutrinolabs/xrdp for more information.

  Configure options:
      --enable-ipv6
      --enable-jpeg
      --enable-fuse
      --enable-rfxcodec
      --enable-opus
      --enable-painter
      --enable-vsock
      --build=x86_64-linux-gnu
      --prefix=/usr
      --includedir=${prefix}/include
      --mandir=${prefix}/share/man
      --infodir=${prefix}/share/info
      --sysconfdir=/etc
      --localstatedir=/var
      --disable-silent-rules
      --libdir=${prefix}/lib/x86_64-linux-gnu
      --libexecdir=${prefix}/lib/x86_64-linux-gnu
      --disable-maintainer-mode
      --disable-dependency-tracking
      --with-socketdir=/run/xrdp/sockdir
      build_alias=x86_64-linux-gnu
      CFLAGS=-g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/xrdp-Fn5kxo/xrdp-0.9.24=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/build/xrdp-Fn5kxo/xrdp-0.9.24=/usr/src/xrdp-0.9.24-4 
      LDFLAGS=-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -Wl,--as-needed
      CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=3 
      PKG_CONFIG_PATH=/build/xrdp-Fn5kxo/xrdp-0.9.24/pkgconfig

  Compiled with OpenSSL 3.0.13 30 Jan 2024

Operating system & version

Ubuntu 24.04 LTS

Installation method

dnf / apt / zypper / pkg / etc

Which backend do you use?

Either

What desktop environment do you use?

No response

Environment xrdp running on

All

What's your client?

All

Area(s) with issue?

Other

Steps to reproduce

Install xrdp + xorgxrdp on a clean installation of Ubuntu 24.04

✔️ Expected Behavior

Desktop works

❌ Actual Behavior

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.
    

Anything else?

No response

@matt335672
Copy link
Member Author

See https://github.com/matt335672/xrdp/wiki/Running-GNOME-on-Ubuntu-24.04-LTS for a draft solution.

@akarl10 - I'd particularly appreciate your comments on this.

When this is a bit more official I'll tidy this up a bit.

@akarl10
Copy link
Contributor

akarl10 commented Apr 30, 2024

See https://github.com/matt335672/xrdp/wiki/Running-GNOME-on-Ubuntu-24.04-LTS for a draft solution.

@akarl10 - I'd particularly appreciate your comments on this.

When this is a bit more official I'll tidy this up a bit.

I currently dont have a ubuntu 24.04 handy, but I'm sure the solution you proposed works.
What is a bit odd tough that running gnome-session via the default means fails so badly..
Did you try if using the command in /usr/share/xsessions/ubuntu-xorg.desktop -> Exec= as parameter for /etc/X11/Xsession and setting only DESKTOP_SESSION and XDG_CURRENT_DESKTOP?

in short this block if using_gnome=1

DESKTOP_SESSION=ubuntu-xorg
export DESKTOP_SESSION
if [ -d /usr/share/xsessions ] \
  && [ -f "/usr/share/xsessions/$DESKTOP_SESSION.desktop" ]; then
  STARTUP=$(grep ^Exec= "/usr/share/xsessions/$DESKTOP_SESSION.desktop")
  STARTUP=${STARTUP#Exec=*}
  XDG_CURRENT_DESKTOP=$(grep ^DesktopNames= "/usr/share/xsessions/$DESKTOP_SESSION.desktop")
  XDG_CURRENT_DESKTOP=${XDG_CURRENT_DESKTOP#DesktopNames=*}
  export XDG_CURRENT_DESKTOP
  exec /etc/X11/Xsession "$STARTUP"
fi

the other variables should be set by scripts in /etc/X11/Xsession.d

by the way: what is currently the Exec= in ubuntu-xorg.desktop?

@matt335672
Copy link
Member Author

Contents of ubuntu-org.desktop:-

[Desktop Entry]
Name=Ubuntu on Xorg
Comment=This session logs you into Ubuntu
Exec=env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --session=ubuntu
TryExec=/usr/bin/gnome-shell
Type=Application
DesktopNames=ubuntu;GNOME;
X-GDM-SessionRegisters=true
X-Ubuntu-Gettext-Domain=gnome-session-46

Running the changes you suggest above results in the following:-

  1. The session has a blue background in place of the Ubuntu 24.04 wallpaper.
  2. Terminals start OK with no delay.
  3. org.freedesktop.IBus.session.GNOME.service still has problems:-
    $ systemctl --user status --state=failed
    × 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 Wed 2024-05-01 09:48:40 BST; 3min 31s ago
        Process: 4828 ExecStart=sh -c exec /usr/bin/ibus-daemon --panel disable $([ "$XDG_SESSION_TYPE" = "x11" ] && echo "--xim") (code=exited, status=255/EXCEPTION)
       Main PID: 4828 (code=exited, status=255/EXCEPTION)
            CPU: 13ms
    
    May 01 09:48:40 ubuntu24 systemd[4339]: Starting org.freedesktop.IBus.session.GNOME.service - IBus Daemon for GNOME...
    May 01 09:48:40 ubuntu24 sh[4828]: current session already has an ibus-daemon.
    May 01 09:48:40 ubuntu24 systemd[4339]: org.freedesktop.IBus.session.GNOME.service: Main process exited, code=exited, status=255/EXCEPTION
    May 01 09:48:40 ubuntu24 systemd[4339]: org.freedesktop.IBus.session.GNOME.service: Failed with result 'exit-code'.
    May 01 09:48:40 ubuntu24 systemd[4339]: Failed to start org.freedesktop.IBus.session.GNOME.service - IBus Daemon for GNOME.
    

The last one of these above is explained by the value of STARTUP by the time the scripts in Xsession.d have run. I dumped all the shell variables out before the very last exec $SESSION. Here's what I got:-

Variables for exec $SESSION
ALTUSERXSESSION='/home/testuser/.Xsession'
BASESTARTUP='env'
CJKV_DEFAULT_DESKTOP='*'
CJKV_LOCALES='zh_TW:zh_HK:zh_SG:zh_CN:ja_JP:ko_KR:vi_VN'
CLUTTER_IM_MODULE='ibus'
DBUS_SESSION_BUS_ADDRESS='unix:path=/run/user/1001/bus'
DEBUGINFOD_URLS='https://debuginfod.ubuntu.com '
DEFAULT_XDG_CONFIG_DIRS='/etc/xdg'
DEFAULT_XDG_DATA_DIRS='/usr/local/share/:/usr/share/'
DESKTOP_SESSION='ubuntu-xorg'
DESKTOP_SETUP_IBUS='GNOME'
DISPLAY=':11.0'
ERRFILE='/home/testuser/.xsession-errors'
GPG_AGENT_INFO='/run/user/1001/gnupg/S.gpg-agent:0:1'
GTK_IM_MODULE='ibus'
GTK_MODULES='gail:atk-bridge'
HOME='/home/testuser'
IFS=' 	
'
IMLAUNCH='/usr/bin/im-launch'
IM_CONFIG_CODE='run_im'
IM_CONFIG_CURRENT_DESKTOP='ubuntu;GNOME;'
IM_CONFIG_DATA='/usr/share/im-config/data'
IM_CONFIG_DEFAULT='/etc/default/im-config'
IM_CONFIG_DEFAULT_MODE='auto'
IM_CONFIG_LC_CTYPE='en_US'
IM_CONFIG_NAME='default'
IM_CONFIG_PHASE='1'
IM_CONFIG_PREFERRED=''
IM_CONFIG_PREFERRED_RULE='zh_CN,fcitx5:zh_TW,fcitx5:zh_HK,fcitx5:zh_SG,fcitx5'
IM_CONFIG_VERBOSE='false'
IM_CONFIG_VERSION='0.57-2'
IM_CONFIG_XINPUTRC_SYS='/etc/X11/xinit/xinputrc'
IM_CONFIG_XINPUTRC_USR='/home/testuser/.xinputrc'
LANG='en_US.UTF-8'
LOGNAME='testuser'
OPTIND='1'
OPTIONFILE='/etc/X11/Xsession.options'
OPTIONS='# $Id: Xsession.options 189 2005-06-11 00:04:27Z branden $
#
# configuration options for /etc/X11/Xsession
# See Xsession.options(5) for an explanation of the available options.
allow-failsafe
allow-user-resources
allow-user-xsession
use-ssh-agent
use-session-dbus'
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
PPID='7530'
PROGNAME='Xsession'
PS1='$ '
PS2='> '
PS4='+ '
PULSE_SCRIPT='/etc/xrdp/pulse/default.pa'
PWD='/home/testuser'
QT_ACCESSIBILITY='1'
QT_IM_MODULE='ibus'
RESOURCEFILE='/etc/X11/Xresources/x11-common'
RESOURCEFILES='/etc/X11/Xresources/x11-common'
SESSIONFILE='/etc/X11/Xsession.d/99x11-common_start'
SESSIONFILES='/etc/X11/Xsession.d/20dbus_xdg-runtime
/etc/X11/Xsession.d/20x11-common_process-args
/etc/X11/Xsession.d/30x11-common_xresources
/etc/X11/Xsession.d/35x11-common_xhost-local
/etc/X11/Xsession.d/40x11-common_xsessionrc
/etc/X11/Xsession.d/50x11-common_determine-startup
/etc/X11/Xsession.d/55gnome-session_gnomerc
/etc/X11/Xsession.d/60x11-common_xdg_path
/etc/X11/Xsession.d/70im-config_launch
/etc/X11/Xsession.d/90atk-adaptor
/etc/X11/Xsession.d/90gpg-agent
/etc/X11/Xsession.d/90qt-a11y
/etc/X11/Xsession.d/90x11-common_ssh-agent
/etc/X11/Xsession.d/90xbrlapi
/etc/X11/Xsession.d/99x11-common_start'
SHELL='/bin/bash'
SSHAGENT='/usr/bin/ssh-agent'
SSHAGENTARGS=''
STARTSSH=''
STARTUP='/usr/bin/ssh-agent   /usr/bin/im-launch env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --session=ubuntu'
STARTUP_FULL_PATH='/usr/bin/env'
SYSRESOURCES='/etc/X11/Xresources'
SYSSESSIONDIR='/etc/X11/Xsession.d'
UID='1001'
USER='testuser'
USERXSESSION='/home/testuser/.xsession'
USERXSESSIONRC='/home/testuser/.xsessionrc'
USRRESOURCES='/home/testuser/.Xresources'
WRITE_TEST='/tmp/tmp.9XHqym4TKk'
XDG_CONFIG_DIRS='/etc/xdg/xdg-ubuntu-xorg:/etc/xdg'
XDG_CURRENT_DESKTOP='ubuntu;GNOME;'
XDG_DATA_DIRS='/usr/share/ubuntu-xorg:/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop'
XDG_RUNTIME_DIR='/run/user/1001'
XDG_SESSION_CLASS='user'
XDG_SESSION_ID='c5'
XDG_SESSION_TYPE='x11'
XMODIFIERS='@im=ibus'
XRDP_PULSE_SINK_SOCKET='xrdp_chansrv_audio_out_socket_11'
XRDP_PULSE_SOURCE_SOCKET='xrdp_chansrv_audio_in_socket_11'
XRDP_SESSION='1'
XRDP_SOCKET_PATH='/run/xrdp/sockdir'
agent_sock='/run/user/1001/gnupg/S.gpg-agent'
brltty='/bin/brltty'
drivers_directory='/lib/brltty'
echo='printf %s\n'
exec_prefix=''
prefix=''
program_directory='/bin'
xbrlapi='/bin/xbrlapi'

Having a look through the files in /etc/X11/Xsession.d/, I can make the following significant comments:-

  1. 55gnome-session_gnomerc will not detect we're running GNOME as it looks at BASESTARTUP which is pointing at env.
  2. 70im-config_launch adds the im-launch prefix to STARTUP. There does not appear to be a way to prevent this.

So I believe it's fair to say that at the moment the X11 session scripts aren't really compatible with GNOME for this OS.

@akarl10
Copy link
Contributor

akarl10 commented May 2, 2024

I'm currently looking through the deb source file of gdm:
gdm does not run /etc/X11/Xsession but /etc/gdm/Xsession

I'm not a bash guru, but I think this will also run /etc/X11/Xsession.d/

# run /etc/X11/Xsession.d/
OPTIONFILE=/etc/X11/Xsession.options
USERXSESSION=$HOME/.xsession
USERXSESSIONRC=$HOME/.xsessionrc
ALTUSERXSESSION=$HOME/.Xsession
if [ -d /etc/X11/Xsession.d ]; then
    for i in `ls /etc/X11/Xsession.d/` ; do
        if [ -r "/etc/X11/Xsession.d/$i"  -a -f "/etc/X11/Xsession.d/$i" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
	    . "/etc/X11/Xsession.d/$i"
        fi
    done
fi

the command passed to this is also the env thing
The Xsession setup would be skipped if X-GDM-BypassXsession=true would be in the .desktop file. This is however only done in X11 mode.

The only other thing is that gdm registers back the session to gdm. but I don't think that has something to do with im-launch issues and blue backgrounds.

what could explain the blue background though is that in the Desktop file the separator is ; whereas in the environment it seems to be ':'. The way this is done in gdm seems to be that it will converted into ':' (actually g_key_file_get_string_list)

maybe something like this makes the background appear? (I'm sure if it does you can come up with a fancier way to do this in bash)

XDG_CURRENT_DESKTOP=${XDG_CURRENT_DESKTOP#DesktopNames=*}
XDG_CURRENT_DESKTOP=$( echo $XDG_CURRENT_DESKTOP | tr \; : )

@matt335672
Copy link
Member Author

I can see that /etc/gdm3/Xsession is being run by gdm by editing the file and adding this at the top:-

exec >/tmp/Xsession.log 2>&1
echo Command: "$*"
env | sort
exit 0

Then when I log in on the console the session exist immediately and I get an Xsession.log
Xsession.log.txt

If I do a similar thing in /etc/xrdp/startwm.sh :-

env | sort >/tmp/startwm.log
exit 1

I get this log:-
startwm.log.txt

By manual comparison, the following potentially important variables are present when launched via gdm3 which aren't from xrdp:-

DESKTOP_SESSION=ubuntu-xorg
GDMSESSION=ubuntu-xorg
GSM_SKIP_SSH_AGENT_WORKAROUND=true
GTK_MODULES=gail:atk-bridge
QT_ACCESSIBILITY=1
SSH_AUTH_SOCK=/run/user/1001/gnupg/S.gpg-agent.ssh
XDG_CURRENT_DESKTOP=ubuntu:GNOME
XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
XDG_SESSION_DESKTOP=ubuntu-xorg

So with that I've put together this /etc/xrdp/startwm.sh which works:-

#!/bin/sh

export DESKTOP_SESSION=ubuntu-xorg
export GDMSESSION=ubuntu-xorg
export GSM_SKIP_SSH_AGENT_WORKAROUND=true
export GTK_MODULES=gail:atk-bridge
export QT_ACCESSIBILITY=1
export SSH_AUTH_SOCK=/run/user/1001/gnupg/S.gpg-agent.ssh
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
export XDG_SESSION_DESKTOP=ubuntu-xorg

STARTUP="env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --session=ubuntu"
exec /etc/gdm3/Xsession "$STARTUP"

I'll see what can be derived from the desktop file and post back.

@Hiero32
Copy link
Contributor

Hiero32 commented May 3, 2024

I think easiest way is to use startwm.sh in devel.

For test, copy startwm.sh in devel to home directory.
And save "[ -n "$XRDP_SESSION" -a -z "$DESKTOP_SESSION" ] && export DESKTOP_SESSION=ubuntu" in /etc/profile.d/90-xrdp-default-desktop.sh

Exec following four steps at home directory:

$ wget -q -r -O startwm.sh https://github.com/neutrinolabs/xrdp/raw/devel/sesman/startwm.sh
$ chmod +x startwm.sh
$ echo "[ -n \"\$XRDP_SESSION\" -a -z \"\$DESKTOP_SESSION\" ] && export DESKTOP_SESSION=ubuntu" > 90-xrdp-default-desktop.sh
$ sudo mv 90-xrdp-default-desktop.sh /etc/profile.d/.

You need to logout local session before connecting to xrdp.
Connct to xrdp.

If this works, move startwm.sh to /etc/xrdp

$ sudo mv startwm.sh /etc/xrdp

I tried this, it works.

@akarl10
Copy link
Contributor

akarl10 commented May 3, 2024

that's actually interresting. the only difference I see in ubuntu.desktop and ubuntu-xorg.desktop is the trailing ; in DesktopNames=
Maybe that's the issue? Note that both use \; whereas the delimiter in the environment is a : when launched through gdm. According to @matt335672 there is no trailing : in the ubuntu-xorg.desktop case

@Hiero32
Copy link
Contributor

Hiero32 commented May 3, 2024

@akarl10

Yes. Confirm Description of Key:"OnlyShowIn, NotShowIn" in the following document.
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

The value of XDG_CURRENT_DESKTOP shall be a colon-separated list of strings.
I do not know why semi-colon is used in DesktopNames= of Ubuntu.

startwm.sh in devel is basically follow what @matt335672 wrote in this thread and Dec 16, 2020 post in
#1723

Confirm line 58 through 73 and line 83 through 187 in
https://github.com/neutrinolabs/xrdp/blob/devel/sesman/startwm.sh

By the way, I changed a bit the step. This get the value of DESKTOP_SESSION from local desktop's environment variable DESKTOP_SESSION.

$ wget -q -r -O startwm.sh https://github.com/neutrinolabs/xrdp/raw/devel/sesman/startwm.sh
$ chmod +x startwm.sh
$ echo "[ -n \"\$XRDP_SESSION\" -a -z \"\$DESKTOP_SESSION\" ] && export DESKTOP_SESSION=$DESKTOP_SESSION" > 90-xrdp-default-desktop.sh
$ sudo mv 90-xrdp-default-desktop.sh /etc/profile.d/.

This way should work for most Ubuntu based distributions.

@matt335672
Copy link
Member Author

Thanks @Hiero32 - that's a great observation. I was looking into a different way to do this, but sticking with what's in devel is a much better idea I think.

I've reproduced your findings. The session seems to work both with and without a trailing ':' on XDG_CURRENT_DESKTOP. So either DESKTOP_SESSION=ubuntu or DESKTOP_SESSION=ubuntu-xorg works for me.

I've got a couple of minor comments on your process above:-

  1. In your 90-xrdp-default-desktop.sh creation, we need to cater for a user setting this up for the first time, in which case DESKTOP_SESSION will be empty. At the moment, we've only looked at GNOME.
  2. File ownerships need to be root:

That gives me a full process of something like this:-

cd /tmp

# Set variable for default desktop (if required)
DESKTOP_SESSION=ubuntu

# Replace startwm.sh with development version
wget -q -r -O startwm.sh https://github.com/neutrinolabs/xrdp/raw/devel/sesman/startwm.sh
sudo chmod 755 ./startwm.sh
sudo chown root: ./startwm.sh
sudo mv ./startwm.sh /etc/xrdp

# Create file to set default desktop
echo "[ -n \"\$XRDP_SESSION\" -a -z \"\$DESKTOP_SESSION\" ] && export DESKTOP_SESSION=$DESKTOP_SESSION" > 90-xrdp-default-desktop.sh
sudo chmod 644 ./90-xrdp-default-desktop.sh
sudo chown root: ./90-xrdp-default-desktop.sh
sudo mv ./90-xrdp-default-desktop.sh /etc/profile.d/

And to reverse it:-

cd /tmp

wget -q -r -O startwm.sh https://salsa.debian.org/debian-remote-team/xrdp/-/raw/debian/0.9.24-3/debian/startwm.sh
sudo chmod 755 ./startwm.sh
sudo chown root: ./startwm.sh
sudo mv ./startwm.sh /etc/xrdp

sudo rm -f /etc/profile.d/90-xrdp-default-desktop.sh

These can be copied directly from Github using the copy button and pasted into a terminal.

@Hiero32
Copy link
Contributor

Hiero32 commented May 4, 2024

@matt335672

Thank you for the correction.

When login is done from GDM and go into desktop environment (e.g. ubuntu desktop), DESKTOP_SESSION is set.
In this case it is not necessary to set DESKTOP_SESSION manually.

When login is done from ssh connected console, DESKTOP_SESSION is empty.
In this case, it is necessary to set DESKTOP_SESSION manually.

There is an important thing regarding XDG_DATA_DIRS.
When a package is installed, some package add one or more values to XDG_DATA_DIRS.
For example, flatpak package put /etc/profile.d/flatpak.sh, in which two values are added to XDG_DATA_DIRS.
In the case flatpak package is installed after /etc/xrdp/startwm.sh is modified,
XDG_DATA_DIRS is still /usr/local/share/:/usr/share/:/var/lib/snapd/desktop.
flatpak does not work as expected.
In the case startwm.sh in devel is used, XDG_DATA_DIRS is set correctly.

@matt335672
Copy link
Member Author

Thanks for the clarification @Hiero32

At some point I'd like to change the way that startwm.sh is run from sesman so that a login shell is always invoked first. That will save us needing to explicitly call /etc/profile and ~/.bashrc - not everyone uses these. That's however a change for another day I think.

@tlemo
Copy link

tlemo commented May 10, 2024

Just a drive by comment: I'm having similar issues with using the Gnome session on Ubuntu 24.04 locally (no xrdp, I just installed the gnome-session package).

Would patching startwm.sh fix the local use case as well?

@Hiero32
Copy link
Contributor

Hiero32 commented May 11, 2024

startwm.sh is executed only in the xrdp session.
Therefor, it does not make influence to the local session.

@Hiero32
Copy link
Contributor

Hiero32 commented May 18, 2024

I'm not sure if this functionality is useful for may users...

GDM and LightDM save current setting of selected desktop environment (DE) per user using AccountsService of freedesktop.org.
It is possible to get saved setting via D-Bus.
DE is the value of Session of org.freedesktop.Accounts.User in case GDM version is 40.1 and after.
DE is the value of XSession of org.freedesktop.Accounts.User in case GDM before version 40.1 and LightDM.
After installation of Ubuntu, the value of Session/XSession is empty.
GDM starts ubuntu desktop if the value of Session/XSession is empty.
When a user selects another DE (e.g. ubuntu-xorg) in the login menu and login, the value is set.
The value of Session/XSession can be read via D-Bus.

$ busctl get-property org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User Session | cut -d" -f2)

or

$ busctl get-property org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User XSession | cut -d" -f2)

Following "90-xrdp-default-desktop.sh" works in Ubuntu 24.04 and 22.04.

if [ -n "$XRDP_SESSION" -a -z "$DESKTOP_SESSION" ]; then SAVEDSESSION=$(busctl get-property org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User Session | cut -d\" -f2) if [ -f /usr/share/xsessions/${SAVEDSESSION}.desktop ]; then export DESKTOP_SESSION=$SAVEDSESSION else export DESKTOP_SESSION=ubuntu fi fi

It is possible to switch DE per user, using above 90-xrdp-default-desktop.sh.
For example, I installed "gnome-session-flashback" package, then:

  1. Select gnome-flashback in gdm login menu and login to local session.
  2. logout of the local session.
  3. login via xrdp.
  4. DE is gnome-flashback at this login. gnome-flashback is just for me.

With this way, I use gnome-flashback DE and other users use ubuntu DE on the same server.
This is convenient for me, though I'm not sure how many users want such usage.

Following "90-xrdp-default-desktop.sh" works in many derivatives base on Ubuntu 24.04/22.04/20.04 and Debian 12/11 which use GDM or LigthDM as display manager.

if [ -n "$XRDP_SESSION" -a -z "$DESKTOP_SESSION" ]; then DESKTOPS=$(ls -1 /usr/share/xsessions | sed -n -e "s/\.desktop$//p") DESKTOP_SESSION=$(echo "$DESKTOPS" | head -n1) if [ "$(echo "$DESKTOPS" | wc -l)" != "1" ]; then SESSIONPROP=XSession if cat /etc/X11/default-display-manager | grep -sq gdm3; then if [ $(/usr/sbin/gdm3 --version | cut -d" " -f2 | cut -d. -f1) -ge 40 ]; then SESSIONPROP=Session; fi fi SAVEDSESSION=$(busctl get-property org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User $SESSIONPROP | cut -d\" -f2) if [ -f /usr/share/xsessions/${SAVEDSESSION}.desktop ]; then DESKTOP_SESSION=$SAVEDSESSION else for DESKTOP in $DESKTOPS; do if [ x$DESKTOP = xubuntu ]; then DESKTOP_SESSION=ubuntu; break elif [ x$DESKTOP = xgnome ]; then DESKTOP_SESSION=gnome; fi done fi fi export DESKTOP_SESSION fi

It is possible to set DE from command line, even in xrdp session. Following commands are examples.
For GDM:

$ busctl call org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User SetSession s gnome-flashback
#confirm
$ busctl get-property org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User Session | cut -d" -f2

For LightDM:

$ busctl call org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User SetXSession s mate
#confirm
$ busctl get-property org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User XSession | cut -d" -f2

To switch DE, Logout then Login is necessary.

@MarioRicalde
Copy link

I've been having random issues when logging into a 24.04 Hyper-V VM. I compiled everything, everything works well once the session is logged in, but there's a random chance it'll just hang after authentication. Just a black screen and a X cursor.

xrdp logs show a successful connection.

@Hiero32
Copy link
Contributor

Hiero32 commented Aug 18, 2024

I faced the same issue.

When this issue occurs, try to login via ssh, and issue following command.

DISPLAY=:10 timeout 0.5 xmessage -iconic x

If this works, issue following command as workaround. This works good in my environment.

sudo bash -c "cat >/etc/xdg/autostart/workaround-xrdp.desktop" <<EOF
[Desktop Entry]
Type=Application
Name=workaround for xrdp
Exec=sh -c 'if [ -n "\$XRDP_SESSION" -a "\$XDG_SESSION_TYPE" = "x11" ]; then sleep 2;timeout 0.5 xmessage -iconic x; fi'
EOF

This issue occurs only in Ubuntu 24.04 ubuntu/gnome desktop, even in local login.
I guess a some kind of timing issue exists.

@MarioRicalde
Copy link

@Hiero32 Thank you very much for taking the time to respond to me with so much detail. That solved my issues.

@Kizan
Copy link

Kizan commented Sep 13, 2024

@Hiero32 Any more detail on this issue? Or on any possible permanent fix for this issue?

Thanks again for your workaround it's been very helpful.

:-)

@Hiero32
Copy link
Contributor

Hiero32 commented Sep 15, 2024

@Kizan
Unfortunately, I don't have time to investigate more.
I guess this issue comes from the implementation of Ubuntu 24.04 + gnome46/ubuntu desktop.
It is not easy to get to real cause.

@matt335672
Copy link
Member Author

@Kizan - did you try the link in this comment?

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

No branches or pull requests

6 participants