Skip to content

Commit

Permalink
Run shell on the Flatpak host
Browse files Browse the repository at this point in the history
When Terminal is running on Flatpak we need to access the host
system, otherwise the app is pretty useless.

Closes: #36
  • Loading branch information
plfiorini committed Apr 5, 2019
1 parent 891be87 commit 454a25c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/lib/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QDir>
#include <QFile>
#include <QRegExp>
#include <QStandardPaths>
#include <QStringList>
#include <QFile>
#include <QtDebug>
Expand Down Expand Up @@ -330,13 +331,27 @@ void Session::run()
// the background color is deemed dark or not
QString backgroundColorHint = _hasDarkBackground ? "COLORFGBG=15;0" : "COLORFGBG=0;15";

QStringList environmentVars = _environment << backgroundColorHint;

// If we are running on Flatpak, we should have access to the host
if (!QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty()) {
QStringList flatpakArgs;
flatpakArgs << QLatin1String("--host");
for (auto env : qAsConst(environmentVars))
flatpakArgs << QStringLiteral("--env=%1").arg(env);
flatpakArgs << exec;
exec = QLatin1String("/usr/bin/flatpak-spawn");
arguments = flatpakArgs;
environmentVars = QStringList();
}

/* if we do all the checking if this shell exists then we use it ;)
* Dont know about the arguments though.. maybe youll need some more checking im not sure
* However this works on Arch and FreeBSD now.
*/
int result = _shellProcess->start(exec,
arguments,
_environment << backgroundColorHint,
environmentVars,
windowId(),
_addToUtmp);

Expand Down

0 comments on commit 454a25c

Please sign in to comment.