1 #pragma once
2 
3 #include <json/json.h>
4 
5 #include <optional>
6 #include <string>
7 
8 #ifndef SYSCONFDIR
9 #define SYSCONFDIR "/etc"
10 #endif
11 
12 namespace waybar {
13 
14 class Config {
15  public:
16   static const std::vector<std::string> CONFIG_DIRS;
17 
18   /* Try to find any of provided names in the supported set of config directories */
19   static std::optional<std::string> findConfigPath(
20       const std::vector<std::string> &names, const std::vector<std::string> &dirs = CONFIG_DIRS);
21 
22   Config() = default;
23 
24   void load(const std::string &config);
25 
getConfig()26   Json::Value &getConfig() { return config_; }
27 
28   std::vector<Json::Value> getOutputConfigs(const std::string &name, const std::string &identifier);
29 
30  private:
31   void setupConfig(Json::Value &dst, const std::string &config_file, int depth);
32   void resolveConfigIncludes(Json::Value &config, int depth);
33   void mergeConfig(Json::Value &a_config_, Json::Value &b_config_);
34 
35   std::string config_file_;
36 
37   Json::Value config_;
38 };
39 }  // namespace waybar
40