check which desktop environment is installed

Hello,

I there a way to check which desktop environment is installed on a machine using only commands in a shell?

Thanks

I found that there is a variable $WINDOWMANAGER that tells you which desktop environment is running.

find /usr/share/xsessions -name “*.desktop” -exec basename “{}” .desktop “;”

provided each oh them did create a .desktop file in /usr/share/xsessions

To be more precize about please_try_again’s warning, you may be satisfied with his solution because it will probably find the “desktop environments” you are most used to. But as a “desktop environment” is just a bunch of software programs and other files that can be put anywhere using standard places or not, how to even find out if something is belonging to a “desktop environment”?

…and you seem to be assuming (this is an interpretation) that there will always be exactly one; other possibilities are none or several; at least, that is an advantage of testing which environment is running rather than installed.

A simple one:


ls -l /usr/share/xsessions/

I saw please_try_again’s one, much more elegant, yet wouldn’t keep away this simple one. I use it a lit myself, if I log in remote on a network where a mix of desktops is used.