How to determine if Linux is using KDE or Gnome

I need to programmatically determine which window manager is running on Linux.

Pseudocode for how it will be used:

if(WindowManagerOfOS.isKDE()){ do.anyThing(); } 

How can i do this? Is it possible?

+7
source share
2 answers
 System.getenv("XDG_CURRENT_DESKTOP") 

returns "GNOME" on my machine. Try in a KDE based window.

see also

+10
source

The official answer: you do not have to care. Both desktop computers comply with existing standards. Both can run each other's software. What are you trying to do? If this is the specific service you are looking for, by default only one distribution is used, you should investigate this instead.

+1
source

All Articles