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 3 // found in the LICENSE file. 4 5 #ifndef BASE_NIX_XDG_UTIL_H_ 6 #define BASE_NIX_XDG_UTIL_H_ 7 8 // XDG refers to http://en.wikipedia.org/wiki/Freedesktop.org . 9 // This file contains utilities found across free desktop environments. 10 // 11 // TODO(brettw) this file should be in app/x11, but is currently used by 12 // net. We should have a net API to allow the embedder to specify the behavior 13 // that it uses XDG for, and then move this file. 14 15 #include "base/base_export.h" 16 17 #ifdef nix 18 #error asdf 19 #endif 20 21 namespace base { 22 23 class Environment; 24 class FilePath; 25 26 namespace nix { 27 28 // The default XDG config directory name. 29 BASE_EXPORT extern const char kDotConfigDir[]; 30 31 // The XDG config directory environment variable. 32 BASE_EXPORT extern const char kXdgConfigHomeEnvVar[]; 33 34 // Utility function for getting XDG directories. 35 // |env_name| is the name of an environment variable that we want to use to get 36 // a directory path. |fallback_dir| is the directory relative to $HOME that we 37 // use if |env_name| cannot be found or is empty. |fallback_dir| may be NULL. 38 // Examples of |env_name| are XDG_CONFIG_HOME and XDG_DATA_HOME. 39 BASE_EXPORT FilePath GetXDGDirectory(Environment* env, const char* env_name, 40 const char* fallback_dir); 41 42 // Wrapper around xdg_user_dir_lookup() from src/base/third_party/xdg-user-dirs 43 // This looks up "well known" user directories like the desktop and music 44 // folder. Examples of |dir_name| are DESKTOP and MUSIC. 45 BASE_EXPORT FilePath GetXDGUserDirectory(const char* dir_name, 46 const char* fallback_dir); 47 48 enum DesktopEnvironment { 49 DESKTOP_ENVIRONMENT_OTHER, 50 DESKTOP_ENVIRONMENT_CINNAMON, 51 DESKTOP_ENVIRONMENT_GNOME, 52 // KDE3, KDE4 and KDE5 are sufficiently different that we count 53 // them as different desktop environments here. 54 DESKTOP_ENVIRONMENT_KDE3, 55 DESKTOP_ENVIRONMENT_KDE4, 56 DESKTOP_ENVIRONMENT_KDE5, 57 DESKTOP_ENVIRONMENT_PANTHEON, 58 DESKTOP_ENVIRONMENT_UNITY, 59 DESKTOP_ENVIRONMENT_XFCE, 60 }; 61 62 // Return an entry from the DesktopEnvironment enum with a best guess 63 // of which desktop environment we're using. We use this to know when 64 // to attempt to use preferences from the desktop environment -- 65 // proxy settings, password manager, etc. 66 BASE_EXPORT DesktopEnvironment GetDesktopEnvironment(Environment* env); 67 68 // Return a string representation of the given desktop environment. 69 // May return NULL in the case of DESKTOP_ENVIRONMENT_OTHER. 70 BASE_EXPORT const char* GetDesktopEnvironmentName(DesktopEnvironment env); 71 // Convenience wrapper that calls GetDesktopEnvironment() first. 72 BASE_EXPORT const char* GetDesktopEnvironmentName(Environment* env); 73 74 } // namespace nix 75 } // namespace base 76 77 #endif // BASE_NIX_XDG_UTIL_H_ 78