xdg_util.h 3.1 KB

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