summaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authorBrenno Lemos <brenno@syndel.is>2023-10-22 19:11:03 -0300
committerGitHub <noreply@github.com>2023-10-22 23:11:03 +0100
commitb135bd6cd4c27a9fd94dfa084e75188463c2eb3b (patch)
tree74f04ca3dd010c41f0fd323187bfd916747da151 /src/config
parent59f27e7f570170783ac01fb46a0ff90e14de53e6 (diff)
workspacerules: Add new optional "default command" for auto-launching apps on new workspaces (#3559)
Diffstat (limited to 'src/config')
-rw-r--r--src/config/ConfigManager.cpp8
-rw-r--r--src/config/ConfigManager.hpp27
2 files changed, 21 insertions, 14 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index f0961aa0..2ecac5c9 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -2,6 +2,7 @@
#include "../managers/KeybindManager.hpp"
#include <string.h>
+#include <string>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@@ -1176,7 +1177,10 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
rules = value.substr(WORKSPACE_DELIM + 1);
}
- auto assignRule = [&](std::string rule) {
+ const static std::string ruleOnCreatedEmtpy = "on-created-empty:";
+ const static int ruleOnCreatedEmtpyLen = ruleOnCreatedEmtpy.length();
+
+ auto assignRule = [&](std::string rule) {
size_t delim = std::string::npos;
if ((delim = rule.find("gapsin:")) != std::string::npos)
wsRule.gapsIn = std::stoi(rule.substr(delim + 7));
@@ -1198,6 +1202,8 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
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(ruleOnCreatedEmtpy)) != std::string::npos)
+ wsRule.onCreatedEmptyRunCmd = cleanCmdForWorkspace(name, rule.substr(delim + ruleOnCreatedEmtpyLen));
};
size_t pos = 0;
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index e637979d..c6c726bf 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -36,19 +36,20 @@ struct SConfigValue {
};
struct SWorkspaceRule {
- std::string monitor = "";
- std::string workspaceString = "";
- std::string workspaceName = "";
- int workspaceId = -1;
- bool isDefault = false;
- bool isPersistent = false;
- std::optional<int64_t> gapsIn;
- std::optional<int64_t> gapsOut;
- std::optional<int64_t> borderSize;
- std::optional<int> border;
- std::optional<int> rounding;
- std::optional<int> decorate;
- std::optional<int> shadow;
+ std::string monitor = "";
+ std::string workspaceString = "";
+ std::string workspaceName = "";
+ int workspaceId = -1;
+ bool isDefault = false;
+ bool isPersistent = false;
+ std::optional<int64_t> gapsIn;
+ std::optional<int64_t> gapsOut;
+ std::optional<int64_t> borderSize;
+ std::optional<int> border;
+ std::optional<int> rounding;
+ std::optional<int> decorate;
+ std::optional<int> shadow;
+ std::optional<std::string> onCreatedEmptyRunCmd;
};
struct SMonitorAdditionalReservedArea {