How can I get the list of available desktop environments?

Suppose I’m on a Linux machine, in a shell session, and I want to obtain the list of options I would have if I logged in graphically and had to choose a desktop environment / session type. I expect a list with items such as "kde", "gnome", "xfce4", "cinnamon" etc.

Notes:

  • I would hope for a distribution-agnostic solution, but if you must know the distro – assume it’s RHEL or Centos-based.
  • I’m not picky about the exact naming scheme, the names can be longer/shorter form, one-per-line or otherwise, that really doesn’t matter.
Asked By: einpoklum

||

The answer is surprisingly simple:

ls /usr/share/{wayland-,x}sessions

will give you the list of session files that your login managers are aware of.

If you want to get the "human" names from all these:

sed -n 's/ *Name=(.*)$/1/p' /usr/share/{wayland-,x}sessions/*.desktop
Answered By: Marcus Müller