aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-06-15 07:41:05 +0100
committerGitHub <[email protected]>2022-06-15 07:41:05 +0100
commit36ea12b315c86e3a1448fe3e695bc5e8bca385a7 (patch)
tree258248f0a53e7c9c66780a5455c237e544149eee
parentfa6530c7e8f5f79041a28456ca91d4641c7ad354 (diff)
parent0c5d2f04b4471c9f408f7b6c1a443957ef8e1779 (diff)
downloadHyprland-36ea12b315c86e3a1448fe3e695bc5e8bca385a7.tar.gz
Hyprland-36ea12b315c86e3a1448fe3e695bc5e8bca385a7.zip
Merge pull request #223 from PowerBall253/main
Create config directory if it doesn't exist
-rw-r--r--src/config/ConfigManager.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 00a451ef..d12e20cd 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -654,7 +654,8 @@ void CConfigManager::loadConfigLoadVars() {
configPaths.clear();
static const char* const ENVHOME = getenv("HOME");
- const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
+ const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
+ const std::string CONFIGPATH = CONFIGPARENTPATH + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
configPaths.push_back(CONFIGPATH);
@@ -667,6 +668,15 @@ void CConfigManager::loadConfigLoadVars() {
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
} catch(...) { /* Probably doesn't exist */}
+ try {
+ if (!std::filesystem::is_directory(CONFIGPARENTPATH))
+ std::filesystem::create_directories(CONFIGPARENTPATH);
+ }
+ catch (...) {
+ parseError = "Broken config file! (Could not create directory)";
+ return;
+ }
+
std::ofstream ofs;
ofs.open(CONFIGPATH, std::ios::trunc);