Skip to content

Commit

Permalink
core: move to anonymous hyprlang categories
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Feb 17, 2024
1 parent 12fff4a commit 5541017
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ CConfigManager::CConfigManager() : m_config(getMainConfigPath().c_str(), Hyprlan
}

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-resume", Hyprlang::STRING{""});

Expand Down Expand Up @@ -50,20 +51,19 @@ Hyprlang::CParseResult CConfigManager::postParse() {
}

for (auto& k : KEYS) {
STimeoutRule rule;
uint64_t timeout = 0;
try {
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;
}
STimeoutRule rule;

Hyprlang::INT timeout = std::any_cast<Hyprlang::INT>(m_config.getSpecialConfigValue("listener", "timeout", k.c_str()));

rule.timeout = timeout;
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()));

if (timeout == -1) {
result.setError("Category has a missing timeout setting");
continue;
}

m_vRules.emplace_back(rule);
}

Expand Down

0 comments on commit 5541017

Please sign in to comment.