0

I'm trying to detect the user's desktop environment (Gnome, KDE, etc) in C.

Currently, I'm doing something like this:

if (getenv("GNOME_DESKTOP_SESSION_ID"))
{
   // if getenv didn't return NULL, GNOME_DESKTOP_SESSION_ID must be defined
}

However, on my system, GNOME_DESKTOP_SESSION_ID is defined to be "this-is-deprecated".

Is there another environment variable (or entirely different way) I could check for the presence of Gnome?

yossarian
  • 1,537
  • 14
  • 21
  • 1
    Related Q&A - [How to determine which window manager is running](http://askubuntu.com/questions/72549/how-to-determine-which-window-manager-is-running). – jweyrich Nov 24 '14 at 00:57
  • 1
    **Note:** much is this is in flux with the the transition of many distros from SysVinit to systemd. As long as the distibution retains `consolekit` your ability to query the desktop session should continue unchanged. If the move to systemd drops consolekit, then desktop registration and session tracking will be desktop defined as it requires patches to each desktop (none of which was cemented on my last check). – David C. Rankin Nov 24 '14 at 01:52

0 Answers0