Skip to content

Commit

Permalink
Execute /etc/X11/Xsession if available
Browse files Browse the repository at this point in the history
Ubuntu already provides a /etc/X11/Xsession script which executes
the /etc/X11/Xsession.d scripts.

Those scripts already do the Xresource merge and other actions.

The last script from /etc/X11/Xsession.d executes the session
command specified by $STARTUP, if that is empty it will try
to determine it by itself with the risk of executing something
else.

With this patch we let distros shipping /etc/X11/Xsession to
execute the designated session command and handle Xresource
merge and stuff like that by itself.

At least two other major distributions such as Fedora and
ArchLinux do not have /etc/X11/Xsession, in that case we
will keep the Xresource merge code path and run the session
command ourselves.

Fixes #449
  • Loading branch information
plfiorini committed Nov 6, 2015
1 parent cb76889 commit 25ab4c7
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions data/scripts/Xsession
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,14 @@ if [ -d /etc/X11/xinit/xinitrc.d ]; then
done
fi

# Load Xsession scripts
# OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
# by the scripts to work
xsessionddir="/etc/X11/Xsession.d"
OPTIONFILE=/etc/X11/Xsession.options
USERXSESSION=$HOME/.xsession
USERXSESSIONRC=$HOME/.xsessionrc
ALTUSERXSESSION=$HOME/.Xsession

if [ -d "$xsessionddir" ]; then
for i in `ls $xsessionddir`; do
script="$xsessionddir/$i"
echo "Loading X session script $script"
if [ -r "$script" -a -f "$script" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
. "$script"
fi
done
# Load Xsession scripts, if any
if [ -x /etc/X11/Xsession ]; then
# Let Xsession execute the session for us
export STARTUP=$session
exec /etc/X11/Xsession
fi

# Merge Xresources
if [ -d /etc/X11/Xresources ]; then
for i in /etc/X11/Xresources/*; do
[ -f $i ] && xrdb -merge $i
Expand All @@ -85,6 +74,7 @@ elif [ -f /etc/X11/Xresources ]; then
fi
[ -f $HOME/.Xresources ] && xrdb -merge $HOME/.Xresources

# Execute the actual session
case $session in
"")
exec xmessage -center -buttons OK:0 -default OK "Sorry, $DESKTOP_SESSION is no valid session."
Expand Down

0 comments on commit 25ab4c7

Please sign in to comment.