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

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

Merged
merged 4 commits into from
Feb 22, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions sesman/startwm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -80,15 +84,24 @@ wm_start()
# debian
if [ -r /etc/X11/Xsession ]; then
pre_start


# if you want to start preferred desktop environment,
# add following line,
# [ -n "$XRDP_SESSION" ] && export DESKTOP_SESSION=<your preferred desktop>
# in either of following file.
# 1. ~/.profile
# 2. create a file (any filename is OK) in /etc/profile.d
# <your preferred desktop> shall be one of "ls -1 /usr/share/xsessions/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest "ls -1 /usr/share/xsessions/" without .desktop suffix

# e.g. [ -n "$XRDP_SESSION" ] && export DESKTOP_SESSION==ubuntu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be DESKTOP_SESSION=ubuntu

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the documentation. This way we give some kind of "best practice" and prevent too many custom solutions/hacks that might break if upstream changes something


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in the PR, please remove this bit.

By all means add a comment to point the user to ~/.profile or /etc/profile.d/

# 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
Expand Down