This commit is contained in:
Mihai Fufezan 2024-07-09 19:55:45 +03:00
parent a5afa58175
commit 2988a27c58
Signed by: fufexan
SSH Key Fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg
1 changed files with 11 additions and 6 deletions

View File

@ -44,20 +44,20 @@ namespace Hyprutils::Path {
using T = std::optional<std::string>;
std::pair<T, T> findConfig(std::string programName) {
bool xdgConfigHomeExists = false;
static const auto xdgConfigHome = getXdgConfigHome();
if (xdgConfigHome.has_value()) {
xdgConfigHomeExists = true;
if (checkConfigExists(xdgConfigHome.value(), programName))
return std::make_pair(fullConfigPath(xdgConfigHome.value(), programName), xdgConfigHome);
else
return std::make_pair(std::nullopt, xdgConfigHome);
}
bool homeExists = false;
static const auto home = getHome();
if (home.has_value()) {
homeExists = true;
if (checkConfigExists(home.value(), programName))
return std::make_pair(fullConfigPath(home.value(), programName), home);
else
return std::make_pair(std::nullopt, home);
}
static const auto xdgConfigDirs = getXdgConfigDirs();
@ -71,6 +71,11 @@ namespace Hyprutils::Path {
if (checkConfigExists("/etc/xdg", programName))
return std::make_pair(fullConfigPath("/etc/xdg", programName), std::nullopt);
if (xdgConfigHomeExists)
return std::make_pair(std::nullopt, xdgConfigHome);
else if (homeExists)
return std::make_pair(std::nullopt, home);
return std::make_pair(std::nullopt, std::nullopt);
}
}