config: fix custom config paths

fixes #172
This commit is contained in:
Vaxry 2025-09-09 13:16:32 +01:00
parent 5430b73ddf
commit f158b2fe92
3 changed files with 10 additions and 11 deletions

View file

@ -18,6 +18,7 @@ CConfigManager::CConfigManager(std::string configPath) :
m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) { m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) {
; ;
configCurrentPath = configPath.empty() ? getMainConfigPath() : configPath; configCurrentPath = configPath.empty() ? getMainConfigPath() : configPath;
configHeadPath = configCurrentPath;
} }
static Hyprlang::CParseResult handleSource(const char* c, const char* v) { static Hyprlang::CParseResult handleSource(const char* c, const char* v) {
@ -51,8 +52,7 @@ void CConfigManager::init() {
m_config.addConfigValue("general:inhibit_sleep", Hyprlang::INT{2}); m_config.addConfigValue("general:inhibit_sleep", Hyprlang::INT{2});
// track the file in the circular dependency chain // track the file in the circular dependency chain
const auto mainConfigPath = getMainConfigPath(); alreadyIncludedSourceFiles.insert(std::filesystem::canonical(configHeadPath));
alreadyIncludedSourceFiles.insert(std::filesystem::canonical(mainConfigPath));
m_config.registerHandler(&::handleSource, "source", {.allowFlags = false}); m_config.registerHandler(&::handleSource, "source", {.allowFlags = false});

View file

@ -22,7 +22,7 @@ class CConfigManager {
std::vector<STimeoutRule> getRules(); std::vector<STimeoutRule> getRules();
std::optional<std::string> handleSource(const std::string&, const std::string&); std::optional<std::string> handleSource(const std::string&, const std::string&);
std::string configCurrentPath; std::string configCurrentPath, configHeadPath;
std::set<std::string> alreadyIncludedSourceFiles; std::set<std::string> alreadyIncludedSourceFiles;
template <typename T> template <typename T>

View file

@ -40,14 +40,13 @@ int main(int argc, char** argv, char** envp) {
else if (arg == "--help" || arg == "-h") { else if (arg == "--help" || arg == "-h") {
Debug::log(NONE, Debug::log(NONE,
"Usage: hypridle [options]\n" "Usage: hypridle [options]\n"
"Options:\n" "Options:\n"
" -v, --verbose Enable verbose logging\n" " -v, --verbose Enable verbose logging\n"
" -q, --quiet Suppress all output except errors\n" " -q, --quiet Suppress all output except errors\n"
" -V, --version Show version information\n" " -V, --version Show version information\n"
" -c, --config <path> Specify a custom config file path\n" " -c, --config <path> Specify a custom config file path\n"
" -h, --help Show this help message" " -h, --help Show this help message");
);
return 0; return 0;
} }
} }