app: use config to determine json config file names
[staging/windowmanager.git] / src / app.cpp
index 93877ba..aa3f644 100644 (file)
@@ -114,27 +114,34 @@ App::App(wl::display *d)
      display{d},
      controller{},
      outputs(),
+     config(),
      layouts(),
      layers() {
    assert(g_app == nullptr);
    g_app = this;
 
-   {
-      auto l = load_layer_map("../ids.json");
-      if (l.is_ok()) {
-         this->layers = l.unwrap();
-      } else {
-         logerror("%s", l.err().value());
+   try {
+      {
+         auto l = load_layer_map(
+                 this->config.get_string("layers.json").value().c_str());
+         if (l.is_ok()) {
+            this->layers = l.unwrap();
+         } else {
+            logerror("%s", l.err().value());
+         }
       }
-   }
 
-   {
-      auto l = load_layout("../layout.json");
-      if (l.is_ok()) {
-         this->layouts = l.unwrap();
-      } else {
-         logerror("%s", l.err().value());
+      {
+         auto l = load_layout(
+                 this->config.get_string("layout.json").value().c_str());
+         if (l.is_ok()) {
+            this->layouts = l.unwrap();
+         } else {
+            logerror("%s", l.err().value());
+         }
       }
+   } catch (std::exception &e) {
+      logerror("Loading of configuration failed: %s", e.what());
    }
 }