I need to find out (using a Shell script/ C program), whether GNOME or KDE is running as the current Desktop manager.
Is there a way to accomplish this? There are some environment variables specific to these ( for example GNOME_DESKTOP_SESSION_ID and GDMSESSION), but I am not sure about the significance of these variables and whether they will always be set with some value?
One thing your could do is write a shell script that could examine the current processes that are running and see if gnome-session or kde-session is running. That should give you an idea of what environment is being used.
I did find one post out there that might be of use.