Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 71 lines 3.1 kB view raw
1diff --git a/src/common/Configuration.h b/src/common/Configuration.h 2index 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")); 10+ 11 // Name Entries (but it's a regular class again) 12 Section(Theme, 13 Entry(ThemeDir, QString, _S(DATA_INSTALL_DIR "/themes"), _S("Theme directory path")); 14diff --git a/src/greeter/SessionModel.cpp b/src/greeter/SessionModel.cpp 15index d8698b7..df3e3c4 100644 16--- a/src/greeter/SessionModel.cpp 17+++ b/src/greeter/SessionModel.cpp 18@@ -49,6 +49,7 @@ namespace SDDM { 19 if (dri_active) 20 populate(Session::WaylandSession, mainConfig.Wayland.SessionDir.get()); 21 populate(Session::X11Session, mainConfig.X11.SessionDir.get()); 22+ selectDefaultSession(); 23 endResetModel(); 24 25 // refresh everytime a file is changed, added or removed 26@@ -62,6 +63,7 @@ namespace SDDM { 27 if (dri_active) 28 populate(Session::WaylandSession, mainConfig.Wayland.SessionDir.get()); 29 populate(Session::X11Session, mainConfig.X11.SessionDir.get()); 30+ selectDefaultSession(); 31 endResetModel(); 32 }); 33 watcher->addPaths(mainConfig.Wayland.SessionDir.get()); 34@@ -164,11 +166,25 @@ namespace SDDM { 35 delete si; 36 } 37 } 38+ } 39+ 40+ void SessionModel::selectDefaultSession() { 41+ d->lastIndex = 0; 42+ 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()) { 46 d->lastIndex = i; 47- break; 48+ return; 49+ } 50+ } 51+ 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) { 56+ d->lastIndex = i; 57+ return; 58 } 59 } 60 } 61diff --git a/src/greeter/SessionModel.h b/src/greeter/SessionModel.h 62index 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 }; 67 68 void populate(Session::Type type, const QStringList &dirPaths); 69+ void selectDefaultSession(); 70 }; 71 }