From 5f54adae7bc4edaf2c18383efe13ded233255509 Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Fri, 16 Jun 2023 00:05:28 +1200 Subject: feat: Uses a backup config file and respects XDG Uses config files in the order of `$XDG_CONFIG_HOME/YATwm/config`, `$HOME/.config/YATwm/config`, then `/etc/YATwm/config` --- config.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'config.cpp') diff --git a/config.cpp b/config.cpp index b17f0e2..5200a4b 100644 --- a/config.cpp +++ b/config.cpp @@ -74,20 +74,28 @@ std::vector Config::reloadFile() std::vector Config::loadFromFile(std::string path) { std::vector errs; - + file = path; + + std::ifstream config(path); + if(!config.good()) + { + config = std::ifstream("/etc/YATwm/config"); + errs.push_back({CFG_ERR_FATAL, "Using default config: /etc/YATwm/config"}); + } + //Set defaults gaps = 3; outerGaps = 3; logFile = "/tmp/yatlog.txt"; numWS = 0; swapSuperAlt = false; + workspaces = std::vector(); //Probably need something for workspaces and binds too... string cmd; int line = 0; - std::ifstream config(path); while(getline(config, cmd)) { if(cmd.size() == 0) -- cgit v1.2.3