content of /etc/X11/xinit/xinitrc.d/11-xdg-menu-kde-4: #!/bin/sh if [ -z "\${XDG_MENU_PREFIX}" ] && [ "\${DESKTOP_SESSION}" = "KDE-4" ]; then export XDG_MENU_PREFIX="kde-4-" fi ${DESKTOP_SESSION} shoude be substituted by ${XSESSION} The script use environment variable ${DESKTOP_SESSION} to decide weather KDE is chosen to start, but Gentoo use ${XSESSION} to indicate which desktop environment to start, and ${DESKTOP_SESSION} is not set by default. Reproducible: Always
It's designed to operate based on the *current* session, which is exported at runtime via DESKTOP_SESSION.