mirror of
https://github.com/hyprwm/hypridle.git
synced 2024-11-16 23:25:58 +01:00
config: Add a -c|--config flag to set a config path (#25)
This commit is contained in:
parent
cc465d04d6
commit
029f08805a
4 changed files with 18 additions and 4 deletions
|
@ -48,3 +48,12 @@ Installation:
|
||||||
```sh
|
```sh
|
||||||
sudo cmake --install build
|
sudo cmake --install build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
```
|
||||||
|
-c <config_path>, --config <config_path>: specify a config path, by default
|
||||||
|
set to ${XDG_CONFIG_HOME}/hypr/hypridle.conf
|
||||||
|
-q, --quiet
|
||||||
|
-v, --verbose
|
||||||
|
```
|
||||||
|
|
|
@ -14,7 +14,7 @@ static std::string getMainConfigPath() {
|
||||||
return getConfigDir() + "/hypr/hypridle.conf";
|
return getConfigDir() + "/hypr/hypridle.conf";
|
||||||
}
|
}
|
||||||
|
|
||||||
CConfigManager::CConfigManager() : m_config(getMainConfigPath().c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) {
|
CConfigManager::CConfigManager(std::string configPath) : m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
class CConfigManager {
|
class CConfigManager {
|
||||||
public:
|
public:
|
||||||
CConfigManager();
|
CConfigManager(std::string configPath);
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
struct STimeoutRule {
|
struct STimeoutRule {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "core/Hypridle.hpp"
|
#include "core/Hypridle.hpp"
|
||||||
|
|
||||||
int main(int argc, char** argv, char** envp) {
|
int main(int argc, char** argv, char** envp) {
|
||||||
|
std::string configPath;
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
std::string arg = argv[i];
|
std::string arg = argv[i];
|
||||||
|
@ -12,10 +13,14 @@ int main(int argc, char** argv, char** envp) {
|
||||||
|
|
||||||
else if (arg == "--quiet" || arg == "-q")
|
else if (arg == "--quiet" || arg == "-q")
|
||||||
Debug::quiet = true;
|
Debug::quiet = true;
|
||||||
|
|
||||||
|
else if (arg == "--config" || arg == "-c") {
|
||||||
|
configPath = argv[++i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
g_pConfigManager = std::make_unique<CConfigManager>();
|
g_pConfigManager = std::make_unique<CConfigManager>(configPath);
|
||||||
g_pConfigManager->init();
|
g_pConfigManager->init();
|
||||||
} catch (const char* err) {
|
} catch (const char* err) {
|
||||||
Debug::log(CRIT, "ConfigManager threw: {}", err);
|
Debug::log(CRIT, "ConfigManager threw: {}", err);
|
||||||
|
|
Loading…
Reference in a new issue