aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-03-05 14:54:26 +0000
committervaxerski <[email protected]>2023-03-05 14:54:32 +0000
commitb03c8970e698312e237fe176ee2654e819c5c202 (patch)
tree3881e736f5b1b317299eef7451bb1fed7817852f /src
parentde5f1b2a833a59d3b0375f24675d27cea99e56d1 (diff)
downloadHyprland-b03c8970e698312e237fe176ee2654e819c5c202.tar.gz
Hyprland-b03c8970e698312e237fe176ee2654e819c5c202.zip
Allow environment in config
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);