summaryrefslogtreecommitdiff
path: root/src/config/supplementary/executor/Executor.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-04-26 15:16:36 +0100
committerGitHub <noreply@github.com>2026-04-26 15:16:36 +0100
commit5ba33f846129f3e6c0505b19f94634b24505e828 (patch)
treeaaacabe678006040c342935481a86607c66607fd /src/config/supplementary/executor/Executor.cpp
parent329b2b356dd92ac07f4e2aa69cbce82ee9ba9d19 (diff)
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.
Diffstat (limited to 'src/config/supplementary/executor/Executor.cpp')
-rw-r--r--src/config/supplementary/executor/Executor.cpp46
1 files changed, 35 insertions, 11 deletions
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<Desktop::Rule::CWindowRule> 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<uint64_t> CExecutor::spawn(const std::string& args) {
return spawnWithRules(args);
}
+std::optional<uint64_t> 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<uint64_t> CExecutor::spawnRaw(const std::string& args) {
return spawnRawProc(args);
}
@@ -104,11 +132,7 @@ std::optional<uint64_t> 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<uint64_t> CExecutor::spawnWithRules(std::string args, PHLWORKSPACE
}
static std::vector<std::pair<std::string, std::string>> getHyprlandLaunchEnv(PHLWORKSPACE pInitialWorkspace) {
- static auto PINITIALWSTRACKING = CConfigValue<Hyprlang::INT>("misc:initial_workspace_tracking");
+ static auto PINITIALWSTRACKING = CConfigValue<Config::INTEGER>("misc:initial_workspace_tracking");
if (!*PINITIALWSTRACKING)
return {};