mirror of
https://github.com/hyprwm/hyprutils.git
synced 2024-12-22 10:49:48 +01:00
ugh
This commit is contained in:
parent
a5afa58175
commit
2988a27c58
1 changed files with 11 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue