diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 22:10:53 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 22:10:53 +0000 |
commit | d6cb85b66439333ea65dfb26d745c8c8d0049aac (patch) | |
tree | ca34fec53150c2dd63e023c2c33ff22a6fd83119 /base/linux_util.cc | |
parent | eeba96cee2c36a2808dcfd0589382524dc3992ad (diff) | |
download | chromium_src-d6cb85b66439333ea65dfb26d745c8c8d0049aac.zip chromium_src-d6cb85b66439333ea65dfb26d745c8c8d0049aac.tar.gz chromium_src-d6cb85b66439333ea65dfb26d745c8c8d0049aac.tar.bz2 |
linux: generalize desktop environment guessing to encompass KDE
BUG=17363
Review URL: http://codereview.chromium.org/159297
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21455 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/linux_util.cc')
-rw-r--r-- | base/linux_util.cc | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/base/linux_util.cc b/base/linux_util.cc index bc99d44..259899f 100644 --- a/base/linux_util.cc +++ b/base/linux_util.cc @@ -99,14 +99,25 @@ EnvironmentVariableGetter* EnvironmentVariableGetter::Create() { return new EnvironmentVariableGetterImpl(); } -bool UseGnomeForSettings(EnvironmentVariableGetter* env_var_getter) { - // GNOME_DESKTOP_SESSION_ID being defined is a good indication that - // we are probably running under GNOME. - // Note: KDE_FULL_SESSION is a corresponding env var to recognize KDE. - std::string dummy, desktop_session; - return env_var_getter->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy) - || (env_var_getter->Getenv("DESKTOP_SESSION", &desktop_session) - && desktop_session == "gnome"); +DesktopEnvironment GetDesktopEnvironment(EnvironmentVariableGetter* env) { + std::string desktop_session; + if (env->Getenv("DESKTOP_SESSION", &desktop_session)) { + if (desktop_session == "gnome") + return DESKTOP_ENVIRONMENT_GNOME; + else if (desktop_session.substr(3) == "kde") // kde3 or kde4 + return DESKTOP_ENVIRONMENT_KDE; + } + + // Fall back on some older environment variables. + // Useful particularly in the DESKTOP_SESSION=default case. + std::string dummy; + if (env->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy)) { + return DESKTOP_ENVIRONMENT_GNOME; + } else if (env->Getenv("KDE_FULL_SESSION", &dummy)) { + return DESKTOP_ENVIRONMENT_KDE; + } + + return DESKTOP_ENVIRONMENT_OTHER; } } // namespace base |