aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorflicko <[email protected]>2024-01-02 21:08:30 +0530
committerGitHub <[email protected]>2024-01-02 16:38:30 +0100
commit4f26c4e1ebf868243dc628182c88d7feb52c8472 (patch)
treea3e5162dd02a11586ae8c5a0cee1e2b473bdfc45
parent3c33d4b9dda3c418a6b842c71720040b092f8510 (diff)
downloadHyprland-4f26c4e1ebf868243dc628182c88d7feb52c8472.tar.gz
Hyprland-4f26c4e1ebf868243dc628182c88d7feb52c8472.zip
config: variables update their value when set again (#4263)
* variables update their value when set again * only sort if new variable is found * clang-format
-rw-r--r--src/config/ConfigManager.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 28959128..44b5374b 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -395,10 +395,20 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
if (!COMMAND.starts_with("device:") /* devices parsed later */ && !COMMAND.starts_with("plugin:") /* plugins parsed later */) {
if (COMMAND[0] == '$') {
// register a dynamic var
- Debug::log(LOG, "Registered dynamic var \"{}\" -> {}", COMMAND, VALUE);
- configDynamicVars.emplace_back(std::make_pair<>(COMMAND.substr(1), VALUE));
+ bool found = false;
+ for (auto& [var, val] : configDynamicVars) {
+ if (var == COMMAND.substr(1)) {
+ Debug::log(LOG, "Registered new value for dynamic var \"{}\" -> {}", COMMAND, VALUE);
+ val = VALUE;
+ found = true;
+ }
+ }
- std::sort(configDynamicVars.begin(), configDynamicVars.end(), [&](const auto& a, const auto& b) { return a.first.length() > b.first.length(); });
+ if (!found) {
+ Debug::log(LOG, "Registered dynamic var \"{}\" -> {}", COMMAND, VALUE);
+ configDynamicVars.emplace_back(std::make_pair<>(COMMAND.substr(1), VALUE));
+ std::sort(configDynamicVars.begin(), configDynamicVars.end(), [&](const auto& a, const auto& b) { return a.first.length() > b.first.length(); });
+ }
} else {
parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">: No such field.";
}