mirror of
https://github.com/hyprwm/hypridle.git
synced 2024-12-22 05:29:49 +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
11
README.md
11
README.md
|
@ -13,7 +13,7 @@ hyprland syntax.
|
|||
|
||||
```ini
|
||||
general {
|
||||
lock_cmd = notify-send "lock!" # dbus/sysd lock command (loginctl lock-session)
|
||||
lock_cmd = notify-send "lock!" # dbus/sysd lock command (loginctl lock-session)
|
||||
unlock_cmd = notify-send "unlock!" # same as above, but unlock
|
||||
before_sleep_cmd = notify-send "Zzz" # command ran before sleep
|
||||
after_sleep_cmd = notify-send "Awake!" # command ran after sleep
|
||||
|
@ -48,3 +48,12 @@ Installation:
|
|||
```sh
|
||||
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";
|
||||
}
|
||||
|
||||
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 {
|
||||
public:
|
||||
CConfigManager();
|
||||
CConfigManager(std::string configPath);
|
||||
void init();
|
||||
|
||||
struct STimeoutRule {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "core/Hypridle.hpp"
|
||||
|
||||
int main(int argc, char** argv, char** envp) {
|
||||
std::string configPath;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::string arg = argv[i];
|
||||
|
@ -12,10 +13,14 @@ int main(int argc, char** argv, char** envp) {
|
|||
|
||||
else if (arg == "--quiet" || arg == "-q")
|
||||
Debug::quiet = true;
|
||||
|
||||
else if (arg == "--config" || arg == "-c") {
|
||||
configPath = argv[++i];
|
||||
}
|
||||
}
|
||||
|
||||
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