|
44 | 44 | #include "TerminalDisplay.h"
|
45 | 45 | #include "ShellCommand.h"
|
46 | 46 | #include "Vt102Emulation.h"
|
| 47 | +#include "utils.h" |
47 | 48 |
|
48 | 49 | // QMLTermWidget
|
49 | 50 | #include <QQuickWindow>
|
@@ -330,13 +331,40 @@ 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 (isRunningOnFlatpak()) { |
| 339 | + QStringList flatpakArgs; |
| 340 | + flatpakArgs << QLatin1String("--host") << QLatin1String("--watch-bus"); |
| 341 | + |
| 342 | + for (const QString &envLine : environmentVars) |
| 343 | + flatpakArgs << QStringLiteral("--env=%1").arg(envLine); |
| 344 | + |
| 345 | + QStringList whitelist; |
| 346 | + whitelist |
| 347 | + << QLatin1String("TERM") << QLatin1String("PATH") |
| 348 | + << QLatin1String("EDITOR") << QLatin1String("PS1") |
| 349 | + << QLatin1String("DISPLAY") << QLatin1String("WAYLAND_DISPLAY"); |
| 350 | + for (const QString &envName : whitelist) { |
| 351 | + const QString value = qEnvironmentVariable(qPrintable(envName)); |
| 352 | + if (!value.isEmpty()) |
| 353 | + flatpakArgs << QStringLiteral("--env=%1=%2").arg(envName).arg(value); |
| 354 | + } |
| 355 | + |
| 356 | + flatpakArgs << exec; |
| 357 | + exec = QLatin1String("/usr/bin/flatpak-spawn"); |
| 358 | + arguments = flatpakArgs; |
| 359 | + } |
| 360 | + |
333 | 361 | /* if we do all the checking if this shell exists then we use it ;)
|
334 | 362 | * Dont know about the arguments though.. maybe youll need some more checking im not sure
|
335 | 363 | * However this works on Arch and FreeBSD now.
|
336 | 364 | */
|
337 | 365 | int result = _shellProcess->start(exec,
|
338 | 366 | arguments,
|
339 |
| - _environment << backgroundColorHint, |
| 367 | + environmentVars, |
340 | 368 | windowId(),
|
341 | 369 | _addToUtmp);
|
342 | 370 |
|
|
0 commit comments