Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if Linux OS uses KDE or Gnome environment

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

Pseudocode for how it would be used:

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

How can I do this? Is it even possible?

like image 353
Carlos Spohr Avatar asked Apr 19 '12 19:04

Carlos Spohr


2 Answers

System.getenv("XDG_CURRENT_DESKTOP")

returns "GNOME" on my machine. Try it out on KDE-based box.

See also

  • Determine what window manager is running?
like image 188
Tomasz Nurkiewicz Avatar answered Sep 22 '22 00:09

Tomasz Nurkiewicz


The official answer is that you aren't supposed to care. Both desktops honor existing standards. Both can run each others' software. What is it you are trying to do? If it's a particular service you are looking for that only one distribution ships by default, you should be probing for that instead.

like image 24
Andy Ross Avatar answered Sep 20 '22 00:09

Andy Ross