9

Is there a way to retrieve the desktop environment name (e.g. Gnome, Unity, XFCE, LXDE, KDE...) from the command line or using Python?

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
giuspen
  • 1,295
  • 2
  • 12
  • 14

1 Answers1

9

In a Terminal input:

echo $DESKTOP_SESSION 

if it does not help (it may be equal 'default'), try

echo $XDG_CURRENT_DESKTOP
PADYMKO
  • 183
  • 1
  • 6
  • 6
    Note that this will not always work as sometimes DESKTOP_SESSION is set to "Default" or in some cases not set at all (I think it's gdm/kdm that set this variable). A better approach would be to check for the running session process. – don_crissti Aug 25 '12 at 17:39
  • I noticed there's also a varable XDG_CURRENT_DESKTOP="LXDE" (or "Unity", in my two desktops), do you think it's reliable? – giuspen Aug 26 '12 at 08:58
  • 1
    @giuspen - discussed also here [link](http://stackoverflow.com/questions/10235117/how-to-detect-if-linux-os-uses-kde-or-gnome-environment). XDG_CURRENT_DESKTOP is just a proposal, it's not part of the XDG spec and is discussed on various mailing lists, e.g. [link](http://www.mail-archive.com/[email protected]/msg06587.html). FIY I am on Gnome3/Arch64bit, I have all the xdg-* packages installed and this variable is unset. – don_crissti Aug 26 '12 at 13:11
  • @don_crissti - thanks I read in the other discussion that you linked that XDG_CURRENT_DESKTOP is deprecated. I will try to look at the running processes. – giuspen Aug 26 '12 at 14:50
  • @giuspen: On Xubuntu 13.04, I get `xubuntu` for `$DESKTOP_SESSION` and `XFCE` for `$XDG_CURRENT_DESKTOP`. – Alix Axel May 30 '13 at 07:19