config: add defaultName for workspace rules

alas, fixes #665
This commit is contained in:
Vaxry 2024-02-27 22:44:42 +00:00
parent e2c286548d
commit f26d7aa58d
3 changed files with 7 additions and 0 deletions

View file

@ -2160,6 +2160,8 @@ std::optional<std::string> CConfigManager::handleWorkspaceRules(const std::strin
wsRule.isDefault = configStringToInt(rule.substr(delim + 8));
else if ((delim = rule.find("persistent:")) != std::string::npos)
wsRule.isPersistent = configStringToInt(rule.substr(delim + 11));
else if ((delim = rule.find("defaultName:")) != std::string::npos)
wsRule.defaultName = rule.substr(delim + 12);
else if ((delim = rule.find(ruleOnCreatedEmtpy)) != std::string::npos)
wsRule.onCreatedEmptyRunCmd = cleanCmdForWorkspace(name, rule.substr(delim + ruleOnCreatedEmtpyLen));
else if ((delim = rule.find("layoutopt:")) != std::string::npos) {

View file

@ -43,6 +43,7 @@ struct SWorkspaceRule {
std::optional<int> decorate;
std::optional<int> shadow;
std::optional<std::string> onCreatedEmptyRunCmd;
std::optional<std::string> defaultName;
std::map<std::string, std::string> layoutopts;
};

View file

@ -24,6 +24,10 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
m_vRenderOffset.registerVar();
m_fAlpha.registerVar();
const auto RULEFORTHIS = g_pConfigManager->getWorkspaceRuleFor(this);
if (RULEFORTHIS.defaultName.has_value())
m_szName = RULEFORTHIS.defaultName.value();
g_pEventManager->postEvent({"createworkspace", m_szName});
EMIT_HOOK_EVENT("createWorkspace", this);
}