Assume a Linux Desktop Environment system is installed. When powered on and credentials entered, whatever Desktop Environment is started i would consider the default Desktop Environment. The user may pick another Desktop Environment such as KDE or XFCE, but that would not be the default. What is a distribution agnostic snippet of code to find the default Desktop Environment or better yet, the DE last used. The code must run from a remote SSH session or CTRL-ALT-F2 text only console.
The impetus for this question is that i recently emailed the output of nvidia-bug-report.sh to NVIDIA. NVIDIA tech support replied back days later asking "What OS?", "GNOME or KDE?", "What Distribution?" - all meta data that could be automatically collected and catalogued by their own script.
Since the Desktop Environment has crashed, nvidia-bug-report.sh needs to run from a CTRL-ALT-F2 text console or remote SSH session. Clearly, neither of these have the $DESKTOP_SESSION variable. Answer would return one or more items in order of confidence from a list similar to
Would like scripts similar to " How can I get distribution name and version number in a simple shell script? "