--- a/usr/portage/x11-apps/xinit/files/chooser.sh 2017-02-28 21:43:13.000000000 +0100 +++ b/usr/portage/x11-apps/xinit/files/chooser.sh 2020-12-07 23:07:30.894288938 +0100 @@ -13,11 +13,21 @@ fi done +# Find a match for $XSESSION in /usr/share/xsessions +DESKTOP_XSESSION="" +for y in /usr/share/xsessions/*.desktop ; do + if [ "`echo ${y##*/} | awk '{ print toupper($1) }'`" \ + = "`echo ${XSESSION}.desktop | awk '{ print toupper($1) }'`" ]; then + DESKTOP_XSESSION=${y} + break + fi +done + GENTOO_EXEC="" if [ -n "${XSESSION}" ]; then - if [ -f /etc/X11/Sessions/${XSESSION} ]; then - if [ -x /etc/X11/Sessions/${XSESSION} ]; then + if [ -f "/etc/X11/Sessions/${XSESSION}" ]; then + if [ -x "/etc/X11/Sessions/${XSESSION}" ]; then GENTOO_EXEC="/etc/X11/Sessions/${XSESSION}" else GENTOO_EXEC="/bin/sh /etc/X11/Sessions/${XSESSION}" @@ -28,7 +38,9 @@ else GENTOO_EXEC="/bin/sh ${GENTOO_SESSION}" fi - else + elif [ -n "${DESKTOP_XSESSION}" ]; then + EXEC="`sed -n -e 's/^Exec=//p' <${DESKTOP_XSESSION}`" + elif [ "${XSESSION}" = "`echo ${XSESSION} | tr -d ' '`" ]; then x="" y="" @@ -42,6 +54,23 @@ break fi done + else # XSESSION contains spaces + EXEC="${XSESSION}" + fi + if [ -n "${EXEC}" ]; then + x="${EXEC%% *}" + if [ "${x}" = "${EXEC}" ]; then + y="" + else + y="${EXEC#* }" + fi + + if [ -x "`which ${x} 2>/dev/null`" ]; then + GENTOO_EXEC="`which ${x} 2>/dev/null`" + if [ -n "${y}" ]; then + GENTOO_EXEC="${GENTOO_EXEC} ${y}" + fi + fi fi fi