Can you test if this solves the problem?
Replace: DESKTOP_SESSION=$(echo $1 | sed "s/gnome-session --session=//g" With: DESKTOP_SESSION=$(grep -l "^Exec=$1\$" /usr/share/xsessions/*.desktop 2>/dev/null | sed -n '1 s,.*/\(.*\)\.desktop,\1,p')
Can you test if this solves the problem?
Replace: SESSION= $(echo $1 | sed "s/gnome-session --session=//g" SESSION= $(grep -l "^Exec=$1\$" /usr/share/ xsessions/ *.desktop 2>/dev/null | sed -n '1 s,.*/\( .*\)\.desktop, \1,p')
DESKTOP_
With:
DESKTOP_