133

as the title:

How can I find which desktop environment I am using?

I want to accomplish this using command line.

Lucio
  • 18,843
Yishu Fang
  • 2,475
  • 2
    this topic is also discussed here – Marius Balaban Apr 25 '12 at 14:29
  • If you are looking for a way to identify xubuntu vs lubuntu vs edubuntu etc. and your OSes were installed via CD, the following might help: grep cdrom: /etc/apt/sources.list | sed -n '1s|.*deb cdrom:\[\([^ ]* *[^ ]*\).*|\1|p' – Marnix A. van Ammers Jul 31 '13 at 23:30
  • 1
    @Luis Alvarado Is desktop environment and window manager are same (because marked as duplicate)? – Pandya Aug 10 '14 at 05:02
  • 2
    @Pandya no, the values will be different, but on the duplicate it shows how to grab the value for both (And other examples for WM and DE). – Luis Alvarado Aug 10 '14 at 15:40
  • 2
    @Lucio, not sure why this question was erroneously marked as a duplicate of a completely different question. Please read this question first and remove the duplicate question marker: https://askubuntu.com/questions/18078/what-is-the-difference-between-a-desktop-environment-and-a-window-manager – Mladen B. Dec 05 '19 at 20:32
  • 1
    Just because the so called "original" contains an answer with solution to this question, does not mean that this question is a duplicate. The desktop environment and window manager are not the same things. These are different questions. The justification for closing this question is, quite simply, wrong, and the decision must be reversed. – MRule Sep 21 '22 at 07:41
  • @Lucio I've tried to elaborate on your edits to finally get the attention of someone with the authority to reverse the marking-as-duplicate. If this doesn't work then there is something seriously wrong with StackExchange! ( : – MRule Sep 21 '22 at 07:47
  • MRule, the duplicate answer also tells how to find the desktop environment, and the title has been edited to reflect this. – Artur Meinild Sep 21 '22 at 08:22

6 Answers6

83

And you can try $DESKTOP_SESSION for the DE.

user55822
  • 3,125
  • 1
  • 17
  • 13
72

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?!)
Pablo Bianchi
  • 15,657
Nadiw
  • 721
29

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" or ps -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.

Pablo Bianchi
  • 15,657
Madiue
  • 291
  • Adding case f (Raspberry Pi 2 running 2016-05-27 Jessie): echo $DESKTOP_SESSION ==> LXDE-pi which says it all. – Richard Elkins Sep 16 '16 at 17:32
  • 4
    What do mean my "HardInfo" ? Can you please explain that – avimehenwal Jun 17 '17 at 08:30
  • @AviMehenwal This answer explains it. – Josiah Yoder Sep 13 '18 at 13:00
  • With gnome under Debian 8.11 DESKTOP_SESSION=default so for me the answer from @Nadew above worked – Till Kolditz Mar 27 '19 at 09:21
  • 3
    in my case, I need to know if i am using unity or lxde, and after testing many commands, I found that env | grep XDG_CURRENT_DESKTOP says what i need. – PHP Learner Aug 09 '19 at 04:17
  • wanted to note a caveat for newbies / folks scripting DE detection logic: if you plan on using ps/prgep, then you will likely need a more complex pattern than suggested above as there are many processes that will give false positives if you simply use the de name by itself. On my system, the only DE is Cinnamon. This comes with gnome-terminal as terminal app. I also have kmag installed. Running ps/pgrep I get false positives for kdevtmpfs and gnome-keyring-daemon even tho gnome & kde are not installed. – zpangwin Apr 20 '21 at 16:39
  • ^ so for detecting in script, I would recommend exhausting env variables (e.g. DESKTOP_SESSION / XDG_CURRENT_DESKTOP / GDMSESSION), then possibly trying to detect based on either session binaries (e.g. ls -acl /usr/bin/*session) or presence of file managers (e.g. test 1 == $(which nemo 2>/dev/null|wc -l) ). Other options not listed in the older answer might also be useful such as : sudo grep -i session /var/lib/AccountsService/users/$USER or grep PREFERRED /etc/sysconfig/desktop but I am not sure how consistently those are used across distros – zpangwin Apr 20 '21 at 16:49
  • Do consider lxqt as a desktop env. – Timo May 16 '21 at 06:36
18

For the window manager you can use:

sudo apt-get install wmctrl
wmctrl -m | grep "Name:" | awk '{print $2}'
Yishu Fang
  • 2,475
  • 1
    You can all about your system by just installing - Sysinfo. Search for it on USC. – Curious Apprentice May 08 '12 at 16:03
  • Sysinfo doesn't tell you which window manager you're using. It only tells you which version of xorg you're running -- at least on my system. – James Bowery Feb 23 '20 at 19:37
  • This is the only answer that seems not only to work but work on all systems and provide output that is concise and incisive -- and I am not talking about "Curious Apprentice"'s answer. Curious Apprentice's "answer" should be ignored as it detracts from the only real answer. – James Bowery Feb 23 '20 at 19:49
  • I would not consider the answer here as appropriate as the window manager is a own issue compared to the desktop env, please correct if I am wrong. – Timo May 16 '21 at 06:37
9

In a terminal or console, you can run:

pgrep -l "gnome|kde|mate|cinnamon"

or

ps -A | egrep -i "gnome|kde|mate|cinnamon"

The item that appears in more lines should be the answer

Lucio
  • 18,843
Adesi
  • 111
  • 1
    I'm getting only 31 kdevtmpfs, 2026 gnome-keyring-d, 2201 polkit-gnome-au, and I'm on xfce. – Klesun Apr 26 '19 at 12:51
  • 1
    same here. added xfce to the regex at least shows something useful, but a lot of heuristics would be required to determine with any certainty what DE you're using – code_monk Jun 15 '20 at 18:56
1

You can run HardInfo. It's ready by default at least in Linux Mint; or you could install it (from Synaptic, ...).

You can run it a) from the main menu > Search box > hardinfo, or b) from the main menu > All applications > System Tools or Administration > System Information, or c) from the main menu > All applications > All > System Information, or d) from a terminal or console > hardinfo > Enter, or e) from the Run Application dialog (Alt+F2) > hardinfo > Enter.

Once HardInfo opens you just need to need to click on the "Operating System" item and look to the "Desktop Environment" line.

Nowadays, apart from GNOME and KDE, you could find MATE, Cinnamon, ...

Adesi
  • 111