summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock6
-rw-r--r--src/config/supplementary/jeremy/Jeremy.cpp41
2 files changed, 17 insertions, 30 deletions
diff --git a/flake.lock b/flake.lock
index 3330ff67..a5ec42eb 100644
--- a/flake.lock
+++ b/flake.lock
@@ -261,11 +261,11 @@
]
},
"locked": {
- "lastModified": 1777492286,
- "narHash": "sha256-PwuoEJQcjSKJNP5T55qhfDwIP0tw5zxEhfu8GDfKfeg=",
+ "lastModified": 1778179779,
+ "narHash": "sha256-Ri6rVf54CRD3aISHLhSY6H4tBScVjm9ebkv7rF2lcZM=",
"owner": "hyprwm",
"repo": "hyprutils",
- "rev": "ec5c0c709706bad5b82f667fd8758eae442577ce",
+ "rev": "3e170e5ad010602671f5f25b327e8bdb8fdd532c",
"type": "github"
},
"original": {
diff --git a/src/config/supplementary/jeremy/Jeremy.cpp b/src/config/supplementary/jeremy/Jeremy.cpp
index 67b7b493..b5548181 100644
--- a/src/config/supplementary/jeremy/Jeremy.cpp
+++ b/src/config/supplementary/jeremy/Jeremy.cpp
@@ -12,41 +12,28 @@ using namespace Config::Supplementary::Jeremy;
std::expected<SConfigStateReply, std::string> Jeremy::getMainConfigPath() {
static bool lastSafeMode = g_pCompositor->m_safeMode;
- static auto regularOrLuaIfAvail = [](std::filesystem::path p) -> std::filesystem::path {
- std::error_code ec;
- auto p2 = p;
- p2.replace_extension(".lua");
-
- // if we don't have a .conf file, use lua by default.
- if (!std::filesystem::exists(p, ec) || ec)
- return p2;
-
- // if we have a .lua file, use that
- if (std::filesystem::exists(p2, ec) && !ec)
- return p2;
-
- // otherwise use .conf
- return p;
- };
-
static auto getCfgPath = []() -> std::expected<SConfigStateReply, std::string> {
lastSafeMode = g_pCompositor->m_safeMode;
if (g_pCompositor->m_safeMode)
- return SConfigStateReply{(std::filesystem::path{g_pCompositor->m_instancePath} / "recoverycfg.conf").string(), CONFIG_TYPE_SPECIAL};
+ return SConfigStateReply{.path = (std::filesystem::path{g_pCompositor->m_instancePath} / "recoverycfg.conf").string(), .type = CONFIG_TYPE_SPECIAL};
if (!g_pCompositor->m_explicitConfigPath.empty())
- return SConfigStateReply{g_pCompositor->m_explicitConfigPath, CONFIG_TYPE_EXPLICIT};
+ return SConfigStateReply{.path = g_pCompositor->m_explicitConfigPath, .type = CONFIG_TYPE_EXPLICIT};
if (const auto CFG_ENV = getenv("HYPRLAND_CONFIG"); CFG_ENV)
- return SConfigStateReply{CFG_ENV, CONFIG_TYPE_EXPLICIT};
-
- const auto PATHS = Hyprutils::Path::findConfig(ISDEBUG ? "hyprlandd" : "hyprland");
- if (PATHS.first.has_value()) {
- return SConfigStateReply{regularOrLuaIfAvail(PATHS.first.value()), CONFIG_TYPE_REGULAR};
- } else if (PATHS.second.has_value()) {
- auto CONFIGPATH = Hyprutils::Path::fullConfigPath(PATHS.second.value(), ISDEBUG ? "hyprlandd" : "hyprland");
- return SConfigStateReply{regularOrLuaIfAvail(CONFIGPATH), CONFIG_TYPE_REGULAR};
+ return SConfigStateReply{.path = CFG_ENV, .type = CONFIG_TYPE_EXPLICIT};
+
+ const auto LUA_PATHS = Hyprutils::Path::findConfig(ISDEBUG ? "hyprlandd" : "hyprland", "lua");
+ const auto CONF_PATHS = Hyprutils::Path::findConfig(ISDEBUG ? "hyprlandd" : "hyprland", "conf");
+
+ if (LUA_PATHS.first.has_value())
+ return SConfigStateReply{.path = LUA_PATHS.first.value(), .type = CONFIG_TYPE_REGULAR};
+ else if (CONF_PATHS.first.has_value())
+ return SConfigStateReply{.path = CONF_PATHS.first.value(), .type = CONFIG_TYPE_REGULAR};
+ else if (LUA_PATHS.second.has_value()) {
+ auto CONFIGPATH = Hyprutils::Path::fullConfigPath(LUA_PATHS.second.value(), ISDEBUG ? "hyprlandd" : "hyprland");
+ return SConfigStateReply{.path = CONFIGPATH, .type = CONFIG_TYPE_REGULAR};
} else
return std::unexpected("Neither HOME nor XDG_CONFIG_HOME are set in the environment. Could not find config in XDG_CONFIG_DIRS or /etc/xdg.");
};