Changeset View
Changeset View
Standalone View
Standalone View
startkde/startplasma.cpp
Context not available. | |||||
179 | // (where <config locations> correspond to the system and user's configuration | 179 | // (where <config locations> correspond to the system and user's configuration | ||
---|---|---|---|---|---|
180 | // directory. | 180 | // directory. | ||
181 | // | 181 | // | ||
182 | // Scripts are sourced in reverse order of priority of their directory, as defined | ||||
183 | // by `QStandardPaths::standardLocations`. This ensures that high-priority scripts | ||||
184 | // (such as those in the user's home directory) are sourced last and take precedence | ||||
185 | // over lower-priority scripts (such as system defaults). Scripts in the same | ||||
186 | // directory are sourced in lexical order of their filename. | ||||
187 | // | ||||
182 | // This is where you can define environment variables that will be available to | 188 | // This is where you can define environment variables that will be available to | ||
183 | // all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent` | 189 | // all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent` | ||
184 | // or eval `gpg-agent --daemon`. | 190 | // or eval `gpg-agent --daemon`. | ||
Context not available. | |||||
191 | void runEnvironmentScripts() | 197 | void runEnvironmentScripts() | ||
192 | { | 198 | { | ||
193 | QStringList scripts; | 199 | QStringList scripts; | ||
194 | const auto locations = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QStringLiteral("plasma-workspace/env"), QStandardPaths::LocateDirectory); | 200 | auto locations = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation); | ||
195 | for (const QString & location : locations) { | 201 | | ||
196 | QDir dir(location); | 202 | //`standardLocations()` returns locations sorted by "order of priority". We iterate in reverse | ||
197 | const auto dirScripts = dir.entryInfoList({QStringLiteral("*.sh")}); | 203 | // order so that high-priority scripts are sourced last and their modifications take precedence. | ||
204 | for (auto loc = locations.crbegin(); loc != locations.crend(); loc++) { | ||||
205 | QDir dir(*loc); | ||||
206 | if (! dir.cd(QStringLiteral("./plasma-workspace/env"))) { | ||||
207 | // Skip location if env/plasma directory does not exist | ||||
208 | continue; | ||||
209 | } | ||||
210 | const auto dirScripts = dir.entryInfoList({QStringLiteral("*.sh")}, QDir::Files, QDir::Name); | ||||
198 | for (const auto script : dirScripts) { | 211 | for (const auto script : dirScripts) { | ||
199 | scripts << script.absoluteFilePath(); | 212 | scripts << script.absoluteFilePath(); | ||
200 | } | 213 | } | ||
Context not available. |