improve "#2522 use startup command from /usr/share/xsession ..."

This commit is contained in:
Hiero32 2023-02-18 10:04:27 +09:00 committed by GitHub
parent 3a2a64dee0
commit 5364ee6aaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,13 +59,17 @@ get_xdg_session_startupcmd()
{
# DESKTOP_SESSION should be set in sesman.ini in the SessionVariables section.
# If set and valid then the STARTUP command will be taken from there
# GDM exports environment variables XDG_CURRENT_DESKTOP and XDG_SESSION_DESKTOP.
# This follows it.
if [ -n "$1" ] && [ -d /usr/share/xsessions ] \
&& [ -f "/usr/share/xsessions/$1.desktop" ]; then
STARTUP=$(grep ^Exec= "/usr/share/xsessions/$1.desktop")
STARTUP=${STARTUP#Exec=*}
XDG_CURRENT_DESKTOP=$(grep ^DesktopNames= "/usr/share/xsessions/$1.desktop")
XDG_CURRENT_DESKTOP=${XDG_CURRENT_DESKTOP#DesktopNames=*}
echo "env XDG_CURRENT_DESKTOP=\"$XDG_CURRENT_DESKTOP\" $STARTUP"
XDG_CURRENT_DESKTOP=${XDG_CURRENT_DESKTOP//;/:}
export XDG_CURRENT_DESKTOP
export XDG_SESSION_DESKTOP="$DESKTOP_SESSION"
fi
}
@ -80,15 +84,23 @@ wm_start()
# debian
if [ -r /etc/X11/Xsession ]; then
pre_start
# if /etc/xrdp/export_desktop_session file exists, souurce it.
# /etc/xrdp/export_desktop_session script exports DESKTOP_SESSION environment varible
# The value shall be one of "ls -1 /usr/share/xsessions|cut -d. -f1".
# e.g. export DESKTOP_SESSION=ubuntu
if [ -r /etc/xrdp/export_desktop_session ]; then
. /etc/xrdp/export_desktop_session
fi
# STARTUP is the default startup command.
# if $1 is empty and STARTUP was not set
# /etc/X11/Xsession.d/50x11-common_determine-startup will fallback to
# x-session-manager
if [ -z "$STARTUP" ] && [ -n "$DESKTOP_SESSION" ]; then
STARTUP="$(get_xdg_session_startupcmd "$DESKTOP_SESSION")"
get_xdg_session_startupcmd "$DESKTOP_SESSION"
fi
. /etc/X11/Xsession
post_start
exit 0