Changeset View
Changeset View
Standalone View
Standalone View
startkde/startplasma.cpp
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | 165 | #endif | |||
---|---|---|---|---|---|
174 | } | 174 | } | ||
175 | qputenv("XCURSOR_SIZE", QByteArray::number(kcminputrc_mouse_cursorsize)); | 175 | qputenv("XCURSOR_SIZE", QByteArray::number(kcminputrc_mouse_cursorsize)); | ||
176 | } | 176 | } | ||
177 | 177 | | |||
178 | // Source scripts found in <config locations>/plasma-workspace/env/*.sh | 178 | // Source scripts found in <config locations>/plasma-workspace/env/*.sh | ||
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`. | ||
185 | // Note: if you do that, you should also put "ssh-agent -k" as a shutdown script | 191 | // Note: if you do that, you should also put "ssh-agent -k" as a shutdown script | ||
186 | // | 192 | // | ||
187 | // (see end of this file). | 193 | // (see end of this file). | ||
188 | // For anything else (that doesn't set env vars, or that needs a window manager), | 194 | // For anything else (that doesn't set env vars, or that needs a window manager), | ||
189 | // better use the Autostart folder. | 195 | // better use the Autostart folder. | ||
190 | 196 | | |||
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 plasma-workspace/env subdirectory 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 | } | ||
201 | } | 214 | } | ||
202 | sourceFiles(scripts); | 215 | sourceFiles(scripts); | ||
203 | } | 216 | } | ||
204 | 217 | | |||
205 | 218 | | |||
▲ Show 20 Lines • Show All 220 Lines • Show Last 20 Lines |