aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp24
-rw-r--r--src/config/ConfigManager.hpp3
2 files changed, 27 insertions, 0 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 5037d9cb..6133f41f 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -31,6 +31,18 @@ CConfigManager::CConfigManager() {
Debug::disableLogs = &configValues["debug:disable_logs"].intValue;
Debug::disableTime = &configValues["debug:disable_time"].intValue;
+
+ populateEnvironment();
+}
+
+void CConfigManager::populateEnvironment() {
+ environmentVariables.clear();
+ for (char** env = environ; *env; ++env) {
+ const std::string ENVVAR = *env;
+ const auto VARIABLE = ENVVAR.substr(0, ENVVAR.find_first_of('='));
+ const auto VALUE = ENVVAR.substr(ENVVAR.find_first_of('=') + 1);
+ environmentVariables[VARIABLE] = VALUE;
+ }
}
void CConfigManager::setDefaultVars() {
@@ -1140,13 +1152,25 @@ void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equals
while (dollarPlace != std::string::npos) {
const auto STRAFTERDOLLAR = line.substr(dollarPlace + 1);
+ bool found = false;
for (auto& [var, value] : configDynamicVars) {
if (STRAFTERDOLLAR.find(var) == 0) {
line.replace(dollarPlace, var.length() + 1, value);
+ found = true;
break;
}
}
+ if (!found) {
+ // maybe env?
+ for (auto& [var, value] : environmentVariables) {
+ if (STRAFTERDOLLAR.find(var) == 0) {
+ line.replace(dollarPlace, var.length() + 1, value);
+ break;
+ }
+ }
+ }
+
dollarPlace = line.find_first_of('$', dollarPlace + 1);
}
}
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index cfb81d56..fd6b40af 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -215,10 +215,13 @@ class CConfigManager {
bool firstExecDispatched = false;
std::deque<std::string> firstExecRequests;
+ std::unordered_map<std::string, std::string> environmentVariables;
+
// internal methods
void setDefaultVars();
void setDefaultAnimationVars();
void setDeviceDefaultVars(const std::string&);
+ void populateEnvironment();
void setAnimForChildren(SAnimationPropertyConfig* const);
void updateBlurredLS(const std::string&, const bool);