mirror of
https://github.com/hyprwm/hypridle.git
synced 2024-12-22 21:39:48 +01:00
core: move to anonymous hyprlang categories
This commit is contained in:
parent
12fff4a122
commit
55410176d4
1 changed files with 10 additions and 10 deletions
|
@ -19,7 +19,8 @@ CConfigManager::CConfigManager() : m_config(getMainConfigPath().c_str(), Hyprlan
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::init() {
|
void CConfigManager::init() {
|
||||||
m_config.addSpecialCategory("listener", Hyprlang::SSpecialCategoryOptions{.key = "timeout"});
|
m_config.addSpecialCategory("listener", Hyprlang::SSpecialCategoryOptions{.key = nullptr, .anonymousKeyBased = true});
|
||||||
|
m_config.addSpecialConfigValue("listener", "timeout", Hyprlang::INT{-1});
|
||||||
m_config.addSpecialConfigValue("listener", "on-timeout", Hyprlang::STRING{""});
|
m_config.addSpecialConfigValue("listener", "on-timeout", Hyprlang::STRING{""});
|
||||||
m_config.addSpecialConfigValue("listener", "on-resume", Hyprlang::STRING{""});
|
m_config.addSpecialConfigValue("listener", "on-resume", Hyprlang::STRING{""});
|
||||||
|
|
||||||
|
@ -50,20 +51,19 @@ Hyprlang::CParseResult CConfigManager::postParse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& k : KEYS) {
|
for (auto& k : KEYS) {
|
||||||
STimeoutRule rule;
|
STimeoutRule rule;
|
||||||
uint64_t timeout = 0;
|
|
||||||
try {
|
Hyprlang::INT timeout = std::any_cast<Hyprlang::INT>(m_config.getSpecialConfigValue("listener", "timeout", k.c_str()));
|
||||||
timeout = std::stoull(std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("listener", "timeout", k.c_str())));
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
result.setError(
|
|
||||||
(std::string{"Faulty rule: cannot parse timeout "} + std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("listener", "timeout", k.c_str()))).c_str());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rule.timeout = timeout;
|
rule.timeout = timeout;
|
||||||
rule.onTimeout = std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("listener", "on-timeout", k.c_str()));
|
rule.onTimeout = std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("listener", "on-timeout", k.c_str()));
|
||||||
rule.onResume = std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("listener", "on-resume", k.c_str()));
|
rule.onResume = std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("listener", "on-resume", k.c_str()));
|
||||||
|
|
||||||
|
if (timeout == -1) {
|
||||||
|
result.setError("Category has a missing timeout setting");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
m_vRules.emplace_back(rule);
|
m_vRules.emplace_back(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue