Skip to content

Commit

Permalink
Greeter: Support setting environment variables
Browse files Browse the repository at this point in the history
Includes a GreeterEnvironment configuration entry.
  • Loading branch information
aleixpol committed Apr 20, 2021
1 parent 34ecafa commit 6398077
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/common/Configuration.h
Expand Up @@ -47,6 +47,7 @@ namespace SDDM {
"NOTE: Currently ignored if autologin is enabled."));
Entry(InputMethod, QString, QStringLiteral("qtvirtualkeyboard"), _S("Input method module"));
Entry(Namespaces, QStringList, QStringList(), _S("Comma-separated list of Linux namespaces for user session to enter"));
Entry(GreeterEnvironment, QStringList, QStringList(), _S("Comma-separated list of environment variables to be set"));
// Name Entries (but it's a regular class again)
Section(Theme,
Entry(ThemeDir, QString, _S(DATA_INSTALL_DIR "/themes"), _S("Theme directory path"));
Expand Down
12 changes: 12 additions & 0 deletions src/helper/HelperApp.cpp
Expand Up @@ -20,6 +20,7 @@

#include "HelperApp.h"
#include "Backend.h"
#include "Configuration.h"
#include "UserSession.h"
#include "SafeDataStream.h"

Expand Down Expand Up @@ -139,6 +140,17 @@ namespace SDDM {
m_user = m_backend->userName();
QProcessEnvironment env = authenticated(m_user);

if (env.value(QStringLiteral("XDG_SESSION_CLASS")) == QLatin1String("greeter")) {
for (const auto &entry : mainConfig.GreeterEnvironment.get()) {
const int index = entry.indexOf(QLatin1Char('='));
if (index < 0) {
qWarning() << "Malformed environment variable" << entry;
continue;
}
env.insert(entry.left(index), entry.mid(index + 1));
}
}

if (!m_session->path().isEmpty()) {
env.insert(m_session->processEnvironment());
m_session->setProcessEnvironment(env);
Expand Down

0 comments on commit 6398077

Please sign in to comment.