mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 12:05:58 +01:00
Allow environment in config
This commit is contained in:
parent
de5f1b2a83
commit
b03c8970e6
2 changed files with 27 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue