1 diff --git a/src/common/Configuration.h b/src/common/Configuration.h
2 index 54bcace..49cf5cb 100644
3 --- a/src/common/Configuration.h
4 +++ b/src/common/Configuration.h
5 @@ -48,6 +48,8 @@ namespace SDDM {
6 Entry(InputMethod, QString, QStringLiteral("qtvirtualkeyboard"), _S("Input method module"));
7 Entry(Namespaces, QStringList, QStringList(), _S("Comma-separated list of Linux namespaces for user session to enter"));
8 Entry(GreeterEnvironment, QStringList, QStringList(), _S("Comma-separated list of environment variables to be set"));
9 + Entry(DefaultSession, QString, QString(), _S("System-wide default session"));
11 // Name Entries (but it's a regular class again)
13 Entry(ThemeDir, QString, _S(DATA_INSTALL_DIR "/themes"), _S("Theme directory path"));
14 diff --git a/src/greeter/SessionModel.cpp b/src/greeter/SessionModel.cpp
15 index d8698b7..df3e3c4 100644
16 --- a/src/greeter/SessionModel.cpp
17 +++ b/src/greeter/SessionModel.cpp
18 @@ -49,6 +49,7 @@ namespace SDDM {
20 populate(Session::WaylandSession, mainConfig.Wayland.SessionDir.get());
21 populate(Session::X11Session, mainConfig.X11.SessionDir.get());
22 + selectDefaultSession();
25 // refresh everytime a file is changed, added or removed
26 @@ -62,6 +63,7 @@ namespace SDDM {
28 populate(Session::WaylandSession, mainConfig.Wayland.SessionDir.get());
29 populate(Session::X11Session, mainConfig.X11.SessionDir.get());
30 + selectDefaultSession();
33 watcher->addPaths(mainConfig.Wayland.SessionDir.get());
34 @@ -164,11 +166,25 @@ namespace SDDM {
40 + void SessionModel::selectDefaultSession() {
43 // find out index of the last session
44 for (int i = 0; i < d->sessions.size(); ++i) {
45 if (d->sessions.at(i)->fileName() == stateConfig.Last.Session.get()) {
52 + // Otherwise, fallback to system-wide default session.
53 + auto defaultSession = mainConfig.DefaultSession.get();
54 + for (int i = 0; i < d->sessions.size(); ++i) {
55 + if (QFileInfo(d->sessions.at(i)->fileName()).fileName() == defaultSession) {
61 diff --git a/src/greeter/SessionModel.h b/src/greeter/SessionModel.h
62 index 8f4d539..02f77ce 100644
63 --- a/src/greeter/SessionModel.h
64 +++ b/src/greeter/SessionModel.h
65 @@ -59,6 +59,7 @@ namespace SDDM {
66 SessionModelPrivate *d { nullptr };
68 void populate(Session::Type type, const QStringList &dirPaths);
69 + void selectDefaultSession();