diff options
| author | BossCode45 <human.cyborg42@gmail.com> | 2023-06-16 00:05:28 +1200 |
|---|---|---|
| committer | BossCode45 <human.cyborg42@gmail.com> | 2023-06-16 00:05:28 +1200 |
| commit | 5f54adae7bc4edaf2c18383efe13ded233255509 (patch) | |
| tree | da3736531e9be6ea57057f7178bfb2baf5a061f9 /config.cpp | |
| parent | 0b539b0b0278f2d7c2b7629e6d28d8463cba2688 (diff) | |
| download | YATwm-5f54adae7bc4edaf2c18383efe13ded233255509.tar.gz YATwm-5f54adae7bc4edaf2c18383efe13ded233255509.zip | |
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`
Diffstat (limited to 'config.cpp')
| -rw-r--r-- | config.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -74,20 +74,28 @@ std::vector<Err> Config::reloadFile() std::vector<Err> Config::loadFromFile(std::string path) { std::vector<Err> 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<Workspace>(); //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) |
