|
35 | 35 | #include <QDir>
|
36 | 36 | #include <QFile>
|
37 | 37 | #include <QRegExp>
|
| 38 | +#include <QStandardPaths> |
38 | 39 | #include <QStringList>
|
39 | 40 | #include <QFile>
|
40 | 41 | #include <QtDebug>
|
@@ -330,13 +331,37 @@ void Session::run()
|
330 | 331 | // the background color is deemed dark or not
|
331 | 332 | QString backgroundColorHint = _hasDarkBackground ? "COLORFGBG=15;0" : "COLORFGBG=0;15";
|
332 | 333 |
|
| 334 | + QStringList environmentVars = _environment; |
| 335 | + environmentVars.append(backgroundColorHint); |
| 336 | + |
| 337 | + // If we are running on Flatpak, we should have access to the host |
| 338 | + if (!QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty()) { |
| 339 | + QStringList flatpakArgs; |
| 340 | + flatpakArgs << QLatin1String("--host") << QLatin1String("--watch-bus"); |
| 341 | + |
| 342 | + for (auto env : environmentVars) |
| 343 | + flatpakArgs << QStringLiteral("--env=%1").arg(env); |
| 344 | + |
| 345 | + const QStringList whitelist = QStringList() |
| 346 | + << QLatin1String("TERM") << QLatin1String("PATH") |
| 347 | + << QLatin1String("DISPLAY") << QLatin1String("WAYLAND_DISPLAY"); |
| 348 | + for (auto env : QProcessEnvironment::systemEnvironment().toStringList()) { |
| 349 | + if (whitelist.contains(env.split(QLatin1Char('=')).first())) |
| 350 | + flatpakArgs << QStringLiteral("--env=%1").arg(env); |
| 351 | + } |
| 352 | + |
| 353 | + flatpakArgs << exec; |
| 354 | + exec = QLatin1String("/usr/bin/flatpak-spawn"); |
| 355 | + arguments = flatpakArgs; |
| 356 | + } |
| 357 | + |
333 | 358 | /* if we do all the checking if this shell exists then we use it ;)
|
334 | 359 | * Dont know about the arguments though.. maybe youll need some more checking im not sure
|
335 | 360 | * However this works on Arch and FreeBSD now.
|
336 | 361 | */
|
337 | 362 | int result = _shellProcess->start(exec,
|
338 | 363 | arguments,
|
339 |
| - _environment << backgroundColorHint, |
| 364 | + environmentVars, |
340 | 365 | windowId(),
|
341 | 366 | _addToUtmp);
|
342 | 367 |
|
|
0 commit comments