From 5ba33f846129f3e6c0505b19f94634b24505e828 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Apr 2026 15:16:36 +0100 Subject: config/lua: init lua config manager, use lua if available (#13817) Adds a new lua config manager, which will automatically be used if there is a lua config present. --- src/config/supplementary/executor/Executor.cpp | 46 ++++++++++++++++++++------ 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'src/config/supplementary/executor/Executor.cpp') diff --git a/src/config/supplementary/executor/Executor.cpp b/src/config/supplementary/executor/Executor.cpp index 8c04df81..70b47a69 100644 --- a/src/config/supplementary/executor/Executor.cpp +++ b/src/config/supplementary/executor/Executor.cpp @@ -37,7 +37,14 @@ CExecutor::CExecutor() { m_firstExecDispatched = true; for (auto const& c : m_execOnce) { - c.withRules ? spawn(c.exec) : spawnRaw(c.exec); + auto res = c.withRules ? spawn(c.exec) : spawnRaw(c.exec); + + if (!res || !c.rule) + continue; + + const auto TOKEN = g_pTokenManager->registerNewToken(nullptr, std::chrono::seconds(1)); + + applyRuleToProc(c.rule, *res, TOKEN); } m_execOnce.clear(); // free some kb of memory :P @@ -61,18 +68,39 @@ CExecutor::CExecutor() { }); } -void CExecutor::addExecOnce(const SExecRequest& cmd) { - m_execOnce.emplace_back(cmd); +void CExecutor::applyRuleToProc(SP rule, int64_t pid, const std::string& token) { + rule->markAsExecRule(token, pid, false /* TODO: could be nice. */); + rule->registerMatch(Desktop::Rule::RULE_PROP_EXEC_TOKEN, token); + rule->registerMatch(Desktop::Rule::RULE_PROP_EXEC_PID, std::to_string(pid)); + Desktop::Rule::ruleEngine()->registerRule(std::move(rule)); + Log::logger->log(Log::DEBUG, "Applied rule arguments for exec, pid {}.", pid); } -void CExecutor::addExecShutdown(const SExecRequest& cmd) { - m_execShutdown.emplace_back(cmd); +void CExecutor::addExecOnce(SExecRequest&& cmd) { + m_execOnce.emplace_back(std::move(cmd)); +} + +void CExecutor::addExecShutdown(SExecRequest&& cmd) { + m_execShutdown.emplace_back(std::move(cmd)); } std::optional CExecutor::spawn(const std::string& args) { return spawnWithRules(args); } +std::optional CExecutor::spawn(const SExecRequest& args) { + auto res = spawn(args.exec); + + if (!args.rule) + return res; + + const auto TOKEN = g_pTokenManager->registerNewToken(nullptr, std::chrono::seconds(1)); + + applyRuleToProc(args.rule, *res, TOKEN); + + return res; +} + std::optional CExecutor::spawnRaw(const std::string& args) { return spawnRawProc(args); } @@ -104,11 +132,7 @@ std::optional CExecutor::spawnWithRules(std::string args, PHLWORKSPACE if (!PROC) return std::nullopt; - rule->markAsExecRule(TOKEN, *PROC, false /* TODO: could be nice. */); - rule->registerMatch(Desktop::Rule::RULE_PROP_EXEC_TOKEN, TOKEN); - rule->registerMatch(Desktop::Rule::RULE_PROP_EXEC_PID, std::to_string(*PROC)); - Desktop::Rule::ruleEngine()->registerRule(std::move(rule)); - Log::logger->log(Log::DEBUG, "Applied rule arguments for exec, pid {}.", *PROC); + applyRuleToProc(rule, *PROC, TOKEN); return PROC; } @@ -117,7 +141,7 @@ std::optional CExecutor::spawnWithRules(std::string args, PHLWORKSPACE } static std::vector> getHyprlandLaunchEnv(PHLWORKSPACE pInitialWorkspace) { - static auto PINITIALWSTRACKING = CConfigValue("misc:initial_workspace_tracking"); + static auto PINITIALWSTRACKING = CConfigValue("misc:initial_workspace_tracking"); if (!*PINITIALWSTRACKING) return {}; -- cgit v1.2.3