How can I find which desktop enviroment I am using?
And you can try $DESKTOP_SESSION
for the DE.
This command seems to be useful:
ls /usr/bin/*session
- in GNOME returns
/usr/bin/gnome-session
(and more) - in MATE returns
/usr/bin/mate-session
(and more) - in LXDE returns
/usr/bin/lxsession
(and more) - in JWM returns
/usr/bin/icewm-session
(should be jwm-session, not?!)
I've tested the best tools I've found with:
a - GNOME under Linux Mint installed
b - GNOME under Linux Mint Live USB
c - MATE under Linux Mint
d - LXDE under Lubuntu
e - JWM under Puppy Linux (JWM is not a desktop environment but a stacking window manager).
f - XFCE under Debian Buster
Results
env | grep DESKTOP_SESSION=
(so-so)a & b - DESKTOP_SESSION=gnome c - DESKTOP_SESSION=default.desktop d - DESKTOP_SESSION=Lubuntu e - Nothing f - DESKTOP_SESSION=xfce
echo $GDMSESSION
(so-so)a & b - gnome c - Nothing d - Lubuntu e - Nothing f - xfce
pgrep -l "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
orps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
(well, but not perfect)a & b - OK c - OK d - WRONG e - Nothing & OK f - OK
HardInfo
(very well, but not perfect)a - Nothing b - GNOME 2.32.0 c - MATE d - LXDE (Lubuntu) e - Unknown (Window Manager: JWM) f - XFCE
Conclusion
A combination of HardInfo
and the command ps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
probably will give the desired answer.