diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index a90b7b7..89f731a 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -30,8 +30,8 @@ static std::string getMainConfigPath() { return getConfigDir() + "/hypr/hyprlock.conf"; } -CConfigManager::CConfigManager() : m_config(getMainConfigPath().c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = true}) { - configCurrentPath = getMainConfigPath(); +CConfigManager::CConfigManager(std::string configPath) : m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = configPath.empty()}) { + configCurrentPath = configPath.empty() ? getMainConfigPath() : configPath; } void CConfigManager::init() { diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index d1b5d87..8b2f373 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -10,7 +10,7 @@ class CConfigManager { public: - CConfigManager(); + CConfigManager(std::string configPath); void init(); void* const* getValuePtr(const std::string& name); diff --git a/src/main.cpp b/src/main.cpp index 094c946..cf47ac0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,11 +7,13 @@ void help() { "Options:\n" " -v, --verbose - Enable verbose logging\n" " -q, --quiet - Disable logging\n" + " -c FILE, --config FILE - Specify config file to use\n" " --display (display) - Specify the Wayland display to connect to\n" " --immediate - Lock immediately, ignoring any configured grace period\n" " -h, --help - Show this help message\n"; } int main(int argc, char** argv, char** envp) { + std::string configPath; std::string wlDisplay; bool immediate = false; @@ -24,6 +26,9 @@ int main(int argc, char** argv, char** envp) { else if (arg == "--quiet" || arg == "-q") Debug::quiet = true; + else if ((arg == "--config" || arg == "-c") && i + 1 < argc) + configPath = argv[++i]; + else if (arg == "--display" && i + 1 < argc) { wlDisplay = argv[i + 1]; i++; @@ -37,7 +42,7 @@ int main(int argc, char** argv, char** envp) { } try { - g_pConfigManager = std::make_unique(); + g_pConfigManager = std::make_unique(configPath); g_pConfigManager->init(); } catch (const char* err) { Debug::log(CRIT, "ConfigManager threw: {}", err);