mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
config: add -c, --config commandline options (#202)
* config: add -c, --config commandline options * argc * don't allow missing custom config file
This commit is contained in:
parent
2ae79757d5
commit
1356f113cc
3 changed files with 9 additions and 4 deletions
|
@ -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() {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
class CConfigManager {
|
||||
public:
|
||||
CConfigManager();
|
||||
CConfigManager(std::string configPath);
|
||||
void init();
|
||||
void* const* getValuePtr(const std::string& name);
|
||||
|
||||
|
|
|
@ -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<CConfigManager>();
|
||||
g_pConfigManager = std::make_unique<CConfigManager>(configPath);
|
||||
g_pConfigManager->init();
|
||||
} catch (const char* err) {
|
||||
Debug::log(CRIT, "ConfigManager threw: {}", err);
|
||||
|
|
Loading…
Reference in a new issue