summaryrefslogtreecommitdiffstats
path: root/base/linux_util.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 22:10:53 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 22:10:53 +0000
commitd6cb85b66439333ea65dfb26d745c8c8d0049aac (patch)
treeca34fec53150c2dd63e023c2c33ff22a6fd83119 /base/linux_util.cc
parenteeba96cee2c36a2808dcfd0589382524dc3992ad (diff)
downloadchromium_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.cc27
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