PDA

View Full Version : Detect Desktop Environment



phannent
19th August 2008, 12:36
Hi,

Is there an easy way to detect the desktop environment?

I want to launch the default calculator and the default on screen keyboard but I do not know how to check if KDE, Gnome or something else is being used.

bitChanger
19th August 2008, 13:13
I don't know how much help this will be to you, but I always perform the following commands from a terminal.



ps -ef | grep startkde

or

ps -ef | grep gnome-session


startkde (to run kde)
gnome-session (to run Gnome)

This will tell you whether kde or gnome is running. You could write code to perform this system call and then parse the return to determine the environment.

Not pretty, but it just might work. :o

jpn
19th August 2008, 14:31
If you want to see how Qt does it, take a look at qt_init() in src/gui/kernel/qapplication_x11.cpp. Search for "X11->desktopEnvironment".