biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / applications / display-managers / sddm / sddm-default-session.patch
blob0227b35c98d73a9be64a78858a2f817a3c88e1ef
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)
12 Section(Theme,
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 {
19 if (dri_active)
20 populate(Session::WaylandSession, mainConfig.Wayland.SessionDir.get());
21 populate(Session::X11Session, mainConfig.X11.SessionDir.get());
22 + selectDefaultSession();
23 endResetModel();
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;
38 + }
40 + void SessionModel::selectDefaultSession() {
41 + d->lastIndex = 0;
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 + }
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;
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();