Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect desktop environment in Linux programmatically in C

I am trying to detect whether I am running on a Gnome or KDE desktop environment.

I know I can check via a ps -aux and grepping either gnome or KDE but that's not good: 1) what if I am on a gnome desktop but I have the KDE libs loaded? 2) I need to do it from code without using system() or popen() or other fork/exec combination.

I can read files, or env. variables or whatever.

Any ideas?

thanks, any help is appreciated.

like image 483
Jessica Avatar asked Aug 16 '10 19:08

Jessica


1 Answers

At least on Opensuse there are the environment variables WINDOWMANAGER, WINDOW_MANAGER

eike@lixie:~> echo $WINDOWMANAGER
/usr/bin/startkde
eike@lixie:~> echo $WINDOW_MANAGER
/usr/bin/startkde
eike@lixie:~>
like image 197
Eike Avatar answered Sep 18 '22 13:09

Eike