Commit 93761e28 authored by Fabian Vogt's avatar Fabian Vogt

Revert "Support importing environment variables from environment.d"

This reverts commit 49346b0b

It broke the wayland session as it picks up WAYLAND_DISPLAY, DISPLAY and others
from dead sessions and also seems to cause other issues, see discussions on
!487
parent 815c6ae8
......@@ -78,11 +78,6 @@ int main(int argc, char** argv)
return 1;
}
// We import systemd environment after we sync the dbus environment here.
// Otherwise it may leads to some unwanted order of applying environment
// variables (e.g. LANG and LC_*)
importSystemdEnvrionment();
QStringList args;
if (argc > 1) {
args.reserve(argc);
......
......@@ -101,11 +101,6 @@ int main(int argc, char** argv)
return 1;
}
// We import systemd environment after we sync the dbus environment here.
// Otherwise it may leads to some unwanted order of applying environment
// variables (e.g. LANG and LC_*)
importSystemdEnvrionment();
if (!startPlasmaSession(false))
return 1;
......
......@@ -88,23 +88,6 @@ int runSync(const QString& program, const QStringList &args, const QStringList &
return p.exitCode();
}
// A helper function to set an environment string in the form of VAR=VALUE.
void setEnvironmentVariable(const QByteArray &env) {
if (env.startsWith("_=") || env.startsWith("SHLVL")) {
return;
}
const int idx = env.indexOf('=');
if (Q_UNLIKELY(idx <= 0)) {
return;
}
if (qgetenv(env.left(idx)) != env.mid(idx+1)) {
// qCDebug(PLASMA_STARTUP) << "setting..." << env.left(idx) << env.mid(idx+1) << "was" << qgetenv(env.left(idx));
qputenv(env.left(idx), env.mid(idx+1));
}
}
void sourceFiles(const QStringList &files)
{
QStringList filteredFiles;
......@@ -123,7 +106,17 @@ void sourceFiles(const QStringList &files)
auto envs = fullEnv.split('\0');
for (auto &env: envs) {
setEnvironmentVariable(env);
if (env.startsWith("_=") || env.startsWith("SHLVL"))
continue;
const int idx = env.indexOf('=');
if (Q_UNLIKELY(idx <= 0))
continue;
if (qgetenv(env.left(idx)) != env.mid(idx+1)) {
// qCDebug(PLASMA_STARTUP) << "setting..." << env.left(idx) << env.mid(idx+1) << "was" << qgetenv(env.left(idx));
qputenv(env.left(idx), env.mid(idx+1));
}
}
}
......@@ -188,37 +181,6 @@ void setupCursor(bool wayland)
qputenv("XCURSOR_SIZE", QByteArray::number(kcminputrc_mouse_cursorsize));
}
// Import systemd user environment.
//
// Systemd read ~/.config/environment.d which applies to all systemd user unit.
// But it won't work if plasma is not started by systemd.
void importSystemdEnvrionment() {
auto msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.systemd1"),
QStringLiteral("/org/freedesktop/systemd1"),
QStringLiteral("org.freedesktop.DBus.Properties"),
QStringLiteral("Get"));
msg << QStringLiteral("org.freedesktop.systemd1.Manager") << QStringLiteral("Environment");
auto reply = QDBusConnection::sessionBus().call(msg);
if (reply.type() == QDBusMessage::ErrorMessage) {
return;
}
// Make sure the returned type is correct.
auto arguments = reply.arguments();
if (arguments.isEmpty() || arguments[0].userType() != qMetaTypeId<QDBusVariant>()) {
return;
}
auto variant = qdbus_cast<QVariant>(arguments[0]);
if (variant.type() != QVariant::StringList) {
return;
}
for (auto &envString : variant.toStringList()) {
setEnvironmentVariable(envString.toLocal8Bit());
}
}
// Source scripts found in <config locations>/plasma-workspace/env/*.sh
// (where <config locations> correspond to the system and user's configuration
// directory.
......
......@@ -34,7 +34,6 @@ void messageBox(const QString &text);
void createConfigDirectory();
void runStartupConfig();
void setupCursor(bool wayland);
void importSystemdEnvrionment();
void runEnvironmentScripts();
void setupPlasmaEnvironment();
void cleanupPlasmaEnvironment();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment