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). My results:
- GNOME under Linux Mint installed;
- GNOME under Linux Mint Live USB;
- MATE under Linux Mint;
- LXDE under Lubuntu;
- JWM under Puppy Linux (so-soJWM is not a desktop environment but a stacking window manager) env | grep DESKTOP_SESSION=.
a)&b) DESKTOP_SESSION=gnome ; c) DESKTOP_SESSION=default.desktop ; d) DESKTOP_SESSION=Lubuntu ; e) (nothing)
- (so-so) echo $GDMSESSION
a)&b) gnome ; c) (nothing) ; d) Lubuntu ; e) (nothing)
- (well, but not perfect) pgrep -l "gnome|kde|mate|cinnamon|lxde|xfce|jwm" or ps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
a)&b) (OK) ; c) (OK) ; d) (WRONG) ; e) (nothing) & (OK)
- (very well, but not perfect) HardInfo
a) (nothing) ; b) GNOME 2.32.0 ; c) MATE ; d) LXDE (Lubuntu) ; e) Unknown (Window ManagerMy results: JWM)
(so-so)
env | grep DESKTOP_SESSION=
- DESKTOP_SESSION=gnome
- DESKTOP_SESSION=gnome
- DESKTOP_SESSION=default.desktop
- DESKTOP_SESSION=Lubuntu
- (nothing)
(so-so)
echo $GDMSESSION
- gnome
- gnome
- (nothing)
- Lubuntu
- (nothing)
(well, but not perfect)
pgrep -l "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
ps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
- (OK)
- (OK)
- (OK)
- (WRONG)
- (nothing) & (OK)
(very well, but not perfect)
HardInfo- (nothing);
- GNOME 2.32.0
- MATE
- LXDE (Lubuntu)
- Unknown (Window Manager: JWM)
CONCLUSION: A combination of HardInfo and the command ps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
ps -A | egrep -i "gnome|kde|mate|cinnamon|lxde|xfce|jwm"
probably will give the desired answer.