OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/nix/xdg_util.h" | 5 #include "base/nix/xdg_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 path = path.Append(fallback_dir); | 50 path = path.Append(fallback_dir); |
51 } | 51 } |
52 return path.StripTrailingSeparators(); | 52 return path.StripTrailingSeparators(); |
53 } | 53 } |
54 | 54 |
55 DesktopEnvironment GetDesktopEnvironment(Environment* env) { | 55 DesktopEnvironment GetDesktopEnvironment(Environment* env) { |
56 // XDG_CURRENT_DESKTOP is the newest standard circa 2012. | 56 // XDG_CURRENT_DESKTOP is the newest standard circa 2012. |
57 std::string xdg_current_desktop; | 57 std::string xdg_current_desktop; |
58 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) { | 58 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) { |
59 // Not all desktop environments set this env var as of this writing. | 59 // Not all desktop environments set this env var as of this writing. |
60 if (xdg_current_desktop == "Unity") | 60 if (xdg_current_desktop == "Unity") { |
| 61 // gnome-fallback sessions set XDG_CURRENT_DESKTOP to Unity |
| 62 // DESKTOP_SESSION can be gnome-fallback or gnome-fallback-compiz |
| 63 std::string desktop_session; |
| 64 if (env->GetVar("DESKTOP_SESSION", &desktop_session) && |
| 65 desktop_session.find("gnome-fallback") != std::string::npos) { |
| 66 return DESKTOP_ENVIRONMENT_GNOME; |
| 67 } |
61 return DESKTOP_ENVIRONMENT_UNITY; | 68 return DESKTOP_ENVIRONMENT_UNITY; |
62 else if (xdg_current_desktop == "GNOME") | 69 } else if (xdg_current_desktop == "GNOME") { |
63 return DESKTOP_ENVIRONMENT_GNOME; | 70 return DESKTOP_ENVIRONMENT_GNOME; |
| 71 } |
64 } | 72 } |
65 | 73 |
66 // DESKTOP_SESSION was what everyone used in 2010. | 74 // DESKTOP_SESSION was what everyone used in 2010. |
67 std::string desktop_session; | 75 std::string desktop_session; |
68 if (env->GetVar("DESKTOP_SESSION", &desktop_session)) { | 76 if (env->GetVar("DESKTOP_SESSION", &desktop_session)) { |
69 if (desktop_session == "gnome") { | 77 if (desktop_session == "gnome") { |
70 return DESKTOP_ENVIRONMENT_GNOME; | 78 return DESKTOP_ENVIRONMENT_GNOME; |
71 } else if (desktop_session == "kde4") { | 79 } else if (desktop_session == "kde4") { |
72 return DESKTOP_ENVIRONMENT_KDE4; | 80 return DESKTOP_ENVIRONMENT_KDE4; |
73 } else if (desktop_session == "kde") { | 81 } else if (desktop_session == "kde") { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 119 } |
112 return NULL; | 120 return NULL; |
113 } | 121 } |
114 | 122 |
115 const char* GetDesktopEnvironmentName(Environment* env) { | 123 const char* GetDesktopEnvironmentName(Environment* env) { |
116 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); | 124 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); |
117 } | 125 } |
118 | 126 |
119 } // namespace nix | 127 } // namespace nix |
120 } // namespace base | 128 } // namespace base |
OLD | NEW |