summary refs log tree commit diff
diff options
context:
space:
mode:
authoroxalica <oxalicc@pm.me>2021-10-29 22:21:40 +0800
committeroxalica <oxalicc@pm.me>2021-11-01 18:57:59 +0800
commit91812b84b8b2ec4051c23bb11d7eb92eba367780 (patch)
tree40bb0e30546faca6d1582f1d7f9f5a5154f28920
parent60f2a331cc9be24230ae62518ae314bb1e9b4a88 (diff)
downloadnixpkgs-91812b84b8b2ec4051c23bb11d7eb92eba367780.tar
nixpkgs-91812b84b8b2ec4051c23bb11d7eb92eba367780.tar.gz
nixpkgs-91812b84b8b2ec4051c23bb11d7eb92eba367780.tar.bz2
nixpkgs-91812b84b8b2ec4051c23bb11d7eb92eba367780.tar.lz
nixpkgs-91812b84b8b2ec4051c23bb11d7eb92eba367780.tar.xz
nixpkgs-91812b84b8b2ec4051c23bb11d7eb92eba367780.tar.zst
nixpkgs-91812b84b8b2ec4051c23bb11d7eb92eba367780.zip
sddm: respect services.xserver.displayManager.defaultSession
-rw-r--r--nixos/modules/services/x11/display-managers/default.nix2
-rw-r--r--nixos/modules/services/x11/display-managers/sddm.nix3
-rw-r--r--pkgs/applications/display-managers/sddm/default.nix1
-rw-r--r--pkgs/applications/display-managers/sddm/sddm-default-session.patch71
4 files changed, 76 insertions, 1 deletions
diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix
index d910ac566d8..bdc46faa7fd 100644
--- a/nixos/modules/services/x11/display-managers/default.nix
+++ b/nixos/modules/services/x11/display-managers/default.nix
@@ -280,7 +280,7 @@ in
             null;
         example = "gnome";
         description = ''
-          Graphical session to pre-select in the session chooser (only effective for GDM and LightDM).
+          Graphical session to pre-select in the session chooser (only effective for GDM, LightDM and SDDM).
 
           On GDM, LightDM and SDDM, it will also be used as a session for auto-login.
         '';
diff --git a/nixos/modules/services/x11/display-managers/sddm.nix b/nixos/modules/services/x11/display-managers/sddm.nix
index 5a4fad9c4cb..529a086381f 100644
--- a/nixos/modules/services/x11/display-managers/sddm.nix
+++ b/nixos/modules/services/x11/display-managers/sddm.nix
@@ -30,6 +30,9 @@ let
       HaltCommand = "/run/current-system/systemd/bin/systemctl poweroff";
       RebootCommand = "/run/current-system/systemd/bin/systemctl reboot";
       Numlock = if cfg.autoNumlock then "on" else "none"; # on, off none
+
+      # Implementation is done via pkgs/applications/display-managers/sddm/sddm-default-session.patch
+      DefaultSession = optionalString (dmcfg.defaultSession != null) "${dmcfg.defaultSession}.desktop";
     };
 
     Theme = {
diff --git a/pkgs/applications/display-managers/sddm/default.nix b/pkgs/applications/display-managers/sddm/default.nix
index 029501c7787..4676e770f1b 100644
--- a/pkgs/applications/display-managers/sddm/default.nix
+++ b/pkgs/applications/display-managers/sddm/default.nix
@@ -19,6 +19,7 @@ in mkDerivation {
 
   patches = [
     ./sddm-ignore-config-mtime.patch
+    ./sddm-default-session.patch
     # Load `/etc/profile` for `environment.variables` with zsh default shell.
     # See: https://github.com/sddm/sddm/pull/1382
     (fetchpatch {
diff --git a/pkgs/applications/display-managers/sddm/sddm-default-session.patch b/pkgs/applications/display-managers/sddm/sddm-default-session.patch
new file mode 100644
index 00000000000..455ebbd4157
--- /dev/null
+++ b/pkgs/applications/display-managers/sddm/sddm-default-session.patch
@@ -0,0 +1,71 @@
+diff --git a/src/common/Configuration.h b/src/common/Configuration.h
+index cf44a62..7bb9c03 100644
+--- a/src/common/Configuration.h
++++ b/src/common/Configuration.h
+@@ -44,6 +44,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(DefaultSession,      QString,     QString(),                                      _S("System-wide default session"));
+         //  Name   Entries (but it's a regular class again)
+         Section(Theme,
+             Entry(ThemeDir,            QString,     _S(DATA_INSTALL_DIR "/themes"),             _S("Theme directory path"));
+diff --git a/src/greeter/SessionModel.cpp b/src/greeter/SessionModel.cpp
+index 1953c76..54fe2f2 100644
+--- a/src/greeter/SessionModel.cpp
++++ b/src/greeter/SessionModel.cpp
+@@ -43,6 +43,7 @@ namespace SDDM {
+         beginResetModel();
+         populate(Session::WaylandSession, mainConfig.Wayland.SessionDir.get());
+         populate(Session::X11Session, mainConfig.X11.SessionDir.get());
++        selectDefaultSession();
+         endResetModel();
+ 
+         // refresh everytime a file is changed, added or removed
+@@ -52,6 +53,7 @@ namespace SDDM {
+             d->sessions.clear();
+             populate(Session::WaylandSession, mainConfig.Wayland.SessionDir.get());
+             populate(Session::X11Session, mainConfig.X11.SessionDir.get());
++            selectDefaultSession();
+             endResetModel();
+         });
+         watcher->addPath(mainConfig.Wayland.SessionDir.get());
+@@ -149,11 +151,25 @@ namespace SDDM {
+             else
+                 delete si;
+         }
++    }
++
++    void SessionModel::selectDefaultSession() {
++        d->lastIndex = 0;
++
+         // find out index of the last session
+         for (int i = 0; i < d->sessions.size(); ++i) {
+             if (d->sessions.at(i)->fileName() == stateConfig.Last.Session.get()) {
+                 d->lastIndex = i;
+-                break;
++                return;
++            }
++        }
++
++        // Otherwise, fallback to system-wide default session.
++        auto defaultSession = mainConfig.DefaultSession.get();
++        for (int i = 0; i < d->sessions.size(); ++i) {
++            if (QFileInfo(d->sessions.at(i)->fileName()).fileName() == defaultSession) {
++                d->lastIndex = i;
++                return;
+             }
+         }
+     }
+diff --git a/src/greeter/SessionModel.h b/src/greeter/SessionModel.h
+index 2e2efa9..a93315c 100644
+--- a/src/greeter/SessionModel.h
++++ b/src/greeter/SessionModel.h
+@@ -58,6 +58,7 @@ namespace SDDM {
+         SessionModelPrivate *d { nullptr };
+ 
+         void populate(Session::Type type, const QString &path);
++        void selectDefaultSession();
+     };
+ }
+