diff --git a/src/path/Path.cpp b/src/path/Path.cpp index d306c88..1376bf7 100644 --- a/src/path/Path.cpp +++ b/src/path/Path.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include using namespace Hyprutils; @@ -11,6 +11,11 @@ namespace Hyprutils::Path { return basePath + "/hypr/" + programName + ".conf"; } + void push_if_new(std::vector vec, std::string str) { + if (std::find(vec.begin(), vec.end(), str) == vec.end()) + vec.push_back(str); + } + std::optional getHome() { static const auto homeDir = getenv("HOME"); @@ -49,23 +54,23 @@ namespace Hyprutils::Path { using T = std::optional; std::pair findConfig(std::string programName) { std::string configPath; - std::set paths; + std::vector paths; static const auto xdgConfigHome = getXdgConfigHome(); if (xdgConfigHome.has_value()) - paths.insert(xdgConfigHome.value()); + push_if_new(paths, xdgConfigHome.value()); static const auto home = getHome(); if (home.has_value()) - paths.insert(home.value()); + push_if_new(paths, home.value()); static const auto xdgConfigDirs = getXdgConfigDirs(); if (xdgConfigDirs.has_value()) { for (auto dir : xdgConfigDirs.value()) - paths.insert(dir); + push_if_new(paths, dir); } - paths.insert("/etc/xdg"); + push_if_new(paths, "/etc/xdg"); for (auto path : paths) { configPath = fullConfigPath(path, programName);