Unable to change background in GDM

I’ve tried using the following patch from here: GDM Background Image and Theme - #3 by notfed

But it was failing on the third step for Gnome 44.
Applied my own like so, but no luck in making it work and show up with background image for GDM.

diff --git a/data/com.ubuntu.login-screen.gschema.xml.in b/data/com.ubuntu.login-screen.gschema.xml.in
new file mode 100644
index 000000000..360929417
--- /dev/null
+++ b/data/com.ubuntu.login-screen.gschema.xml.in
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+  <enum id="com.ubuntu.login-screen.BackgroundRepeat">
+    <value value="1" nick="default"/>
+    <value value="2" nick="repeat"/>
+    <value value="3" nick="repeat-x"/>
+    <value value="4" nick="repeat-y"/>
+    <value value="5" nick="no-repeat"/>
+    <value value="6" nick="space"/>
+    <value value="7" nick="round"/>
+  </enum>
+  <enum id="com.ubuntu.login-screen.BackgroundSize">
+    <value value="1" nick="default"/>
+    <value value="2" nick="auto"/>
+    <value value="3" nick="cover"/>
+    <value value="4" nick="contain"/>
+  </enum>
+  <schema id="com.ubuntu.login-screen" path="/com/ubuntu/login-screen/">
+    <key name="background-picture-uri" type="s">
+      <default>''</default>
+      <summary>
+        Sets the background image for the login screen.
+      </summary>
+      <description>
+        URI to use for the background image. Note that the backend only
+        supports local (file://) URIs.
+        It overrides the value defined in the default style sheet.
+      </description>
+    </key>
+    <key name="background-color" type="s">
+      <default>''</default>
+      <summary>
+        The background-color property sets the background color.
+      </summary>
+      <description>
+        The background-color property sets the background color to use when
+        the background picture URI is missing or when it doesn't cover the whole background.
+        It overrides the value defined in the default style sheet.
+      </description>
+    </key>
+    <key name="background-repeat" enum="com.ubuntu.login-screen.BackgroundRepeat">
+      <default>'default'</default>
+      <summary>
+        The background-repeat property sets if/how the background image will be repeated.
+      </summary>
+      <description>
+        The background-repeat property sets if/how a background image will be repeated.
+        By default, a background-image is repeated both vertically and horizontally.
+
+        It overrides the value defined in the default style sheet.
+      </description>
+    </key>
+    <key name="background-size" enum="com.ubuntu.login-screen.BackgroundSize">
+      <default>'default'</default>
+      <summary>
+        The background-size property specifies the size of the background image.
+      </summary>
+      <description>
+        The background-size property specifies the size of the background images.
+
+        There are three keywords you can use with this property:
+        auto: The background image is displayed in its original size;
+        cover: Resize the background image to cover the entire container, even if it has to stretch the image or cut a little bit off one of the edges;
+        contain: Resize the background image to make sure the image is fully visible.
+
+        It overrides the value defined in the default style sheet.
+      </description>
+    </key>
+  </schema>
+</schemalist>
\ No newline at end of file
diff --git a/data/meson.build b/data/meson.build
index a31efcc79..4fdf1d37d 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -97,6 +97,12 @@ schema = configure_file(
   configuration: schemaconf,
   install_dir: schemadir
 )
+schemaubuntu = configure_file(
+  input: 'com.ubuntu.login-screen.gschema.xml.in',
+  output: 'com.ubuntu.login-screen.gschema.xml',
+  configuration: schemaconf,
+  install_dir: schemadir
+)
 install_data('00_org.gnome.shell.gschema.override', install_dir: schemadir)
 
 if have_systemd
@@ -125,7 +131,7 @@ endif
 
 # for unit tests - gnome.compile_schemas() only looks in srcdir
 custom_target('compile-schemas',
-  input: schema,
+  input: [schema, schemaubuntu],
   output: 'gschemas.compiled',
   command: [find_program('glib-compile-schemas'), data_builddir],
   build_by_default: true)
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index f8c59fa97..d502c2563 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -32,6 +32,12 @@ const DISABLE_LOCK_KEY = 'disable-lock-screen';
 
 const LOCKED_STATE_STR = 'screenShield.locked';
 
+const LOGINSCREEN_SCHEMA = 'com.ubuntu.login-screen';
+const LOGINSCREEN_BACKGROUND_COLOR_KEY = 'background-color';
+const LOGINSCREEN_BACKGROUND_PICTURE_URI_KEY = 'background-picture-uri';
+const LOGINSCREEN_BACKGROUND_REPEAT_KEY = 'background-repeat';
+const LOGINSCREEN_BACKGROUND_SIZE_KEY = 'background-size';
+
 // ScreenShield animation time
 // - STANDARD_FADE_TIME is used when the session goes idle
 // - MANUAL_FADE_TIME is used for lowering the shield when asked by the user,
@@ -114,6 +120,13 @@ export class ScreenShield extends Signals.EventEmitter {
         this._lockSettings = new Gio.Settings({schema_id: LOCKDOWN_SCHEMA});
         this._lockSettings.connect(`changed::${DISABLE_LOCK_KEY}`, this._syncInhibitor.bind(this));
 
+        this._loginscreenSettings = new Gio.Settings({ schema_id: LOGINSCREEN_SCHEMA });
+        this._loginscreenSettings.connect('changed::%s'.format(LOGINSCREEN_BACKGROUND_COLOR_KEY), this._refreshBackground.bind(this));
+        this._loginscreenSettings.connect('changed::%s'.format(LOGINSCREEN_BACKGROUND_PICTURE_URI_KEY), this._refreshBackground.bind(this));
+        this._loginscreenSettings.connect('changed::%s'.format(LOGINSCREEN_BACKGROUND_REPEAT_KEY), this._refreshBackground.bind(this));
+        this._loginscreenSettings.connect('changed::%s'.format(LOGINSCREEN_BACKGROUND_SIZE_KEY), this._refreshBackground.bind(this));
+        this._refreshBackground()
+
         this._isModal = false;
         this._isGreeter = false;
         this._isActive = false;
@@ -214,6 +227,26 @@ export class ScreenShield extends Signals.EventEmitter {
         return this._isModal;
     }
 
+    _refreshBackground() {
+        let inline_style = [];
+
+        let backgroundColor = this._loginscreenSettings.get_string(LOGINSCREEN_BACKGROUND_COLOR_KEY);
+        let backgroundPictureUri = this._loginscreenSettings.get_string(LOGINSCREEN_BACKGROUND_PICTURE_URI_KEY);
+        let backgroundRepeat = this._loginscreenSettings.get_string(LOGINSCREEN_BACKGROUND_REPEAT_KEY);
+        let backgroundSize = this._loginscreenSettings.get_string(LOGINSCREEN_BACKGROUND_SIZE_KEY);
+
+        if (backgroundColor != "")
+            inline_style.push("background-color: " + backgroundColor);
+        if (backgroundPictureUri != "")
+            inline_style.push("background-image: url(" + backgroundPictureUri + ")");
+        if (backgroundRepeat != "default")
+            inline_style.push("background-repeat: " + backgroundRepeat);
+        if (backgroundSize != "default")
+            inline_style.push("background-size: " + backgroundSize);
+
+        this._lockDialogGroup.set_style(inline_style.join('; '));
+    }
+
     async _syncInhibitor() {
         const lockEnabled = this._settings.get_boolean(LOCK_ENABLED_KEY);
         const lockLocked = this._lockSettings.get_boolean(DISABLE_LOCK_KEY);

What do you mean it is failing? Is there an error message?

No error message, just it does not apply background image I’ve selected, tried with .png/.jpg both fail.

This is what I have setup currently in my config: https://github.com/cafetestrest/nixos/blob/affefd204003da8bff666f4c69514a500bc9ea27/modules/gdm/background/default.nix

What am I doing wrong?

That looks correct to me and I tried it in a VM as well and could not make it work either. I also tried passing the setting using the new programs.dconf.profiles.gdm.databases option in case extraGSettingsOverrides did not filter through but nada.

Perhaps the layout of the login screen changed since the patch was written so while it applies, it no longer has any effect. Would be nice to get a confirmation from people who used it in the past.

I decided to go a different way. Looking at the source code, I found relevant part and the following appears to work:

  nixpkgs = {
    overlays = [
      (self: super: {
        gnome = super.gnome.overrideScope' (selfg: superg: {
          gnome-shell = superg.gnome-shell.overrideAttrs (old: {
            patches = (old.patches or []) ++ [
              (let
                bg = pkgs.fetchurl {
                  url = "https://orig00.deviantart.net/0054/f/2015/129/b/9/reflection_by_yuumei-d8sqdu2.jpg";
                  sha256 = "0f0vlmdj5wcsn20qg79ir5cmpmz5pysypw6a711dbaz2r9x1c79l";
                };
              in pkgs.writeText "bg.patch" ''
                --- a/data/theme/gnome-shell-sass/widgets/_login-lock.scss
                +++ b/data/theme/gnome-shell-sass/widgets/_login-lock.scss
                @@ -15,4 +15,5 @@ $_gdm_dialog_width: 23em;
                 /* Login Dialog */
                 .login-dialog {
                   background-color: $_gdm_bg;
                +  background-image: url('file://${bg}');
                 }
              '')
            ];
          });
        });
      })
    ];
  };

I also managed to make your patch work with the following:

(pkgs.writeText "bg.patch" ''
  --- a/data/theme/gnome-shell-sass/widgets/_login-lock.scss
  +++ b/data/theme/gnome-shell-sass/widgets/_login-lock.scss
  @@ -15,4 +15,4 @@ $_gdm_dialog_width: 23em;
   /* Login Dialog */
   .login-dialog {
  -  background-color: $_gdm_bg;
  +  background-color: transparent;
   }
'')

But like the patch in previous comment, it still requires other changes for the texts to be readable.

It might have gotten broken by the changes that display blurred background on lock screen. You might want to also check the following source files:

how to set local image it is working btw

I was able to set it locally only under /etc/nixos folder by modifying the patch like so:

background-image: url('file:///etc/nixos/lockscreen.jpg');

Didn’t have any luck by specifying /home/user directory though, that is not working for me.

Right, GDM runs as gdm user so it will not have access to users’ home directories by default.

I tried in MATE + GDM (it should use GNOME 45) and I get the following error:

building Nix...
building the system configuration...
these 25 derivations will be built:
  /nix/store/3j36k7vz9hiw0bn2knar530p62l89y42-system-path.drv
  /nix/store/fsvg01g0zvw8kkx9i9b2ivzmnc9kx9gm-set-environment.drv
  /nix/store/1ncfy6q26vy6hfp9ym02h1j4j8lmy4mf-etc-fish-nixos-env-preinit.fish.drv
  /nix/store/dfjbcwamj7dns77m69xp0xqrag0jhy6f-reflection_by_yuumei-d8sqdu2.jpg.drv
  /nix/store/syqll0r21q35w2ch35xbz6qc20yydk58-bg.patch.drv
  /nix/store/dx04jfp285q525pb78jpggh1032klmxp-gnome-shell-45.3.drv
  /nix/store/s1imc3ca2ydr21mg1bjfaggcm442ylgg-gnome-session-45.0.drv
  /nix/store/3nab2p5bzxj0ddhdsxvx8vrgyrwbi906-system-generators.drv
  /nix/store/fsnwf76svz1059gzyp8086l1gj01x1la-X-Restart-Triggers-polkit.drv
  /nix/store/4xbwa0q5asw8481d6ygpn97dpjh8adaz-unit-polkit.service.drv
  /nix/store/laz9ah36n851wcpm7c9imj3j8gy3sfcw-unit-display-manager.service.drv
  /nix/store/sv27bxhjpiqil1786b0vvchld5j479nn-dbus-1.drv
  /nix/store/kkiwf5jx2wawq4l9qqipj17493vfl3j7-X-Restart-Triggers-dbus.drv
  /nix/store/mgaqhgaxqbrqlyxdqp4zq7scch0x3d0d-unit-dbus.service.drv
  /nix/store/p7a774pf42hha92hfqdbp07q80hz6r78-unit-accounts-daemon.service.drv
  /nix/store/7hpi8sljkq5mq5jx1ankpw5rpn2a4s1i-system-units.drv
  /nix/store/86x53a8i3jjidgaw7n4b0yyfx184kbin-etc-profile.drv
  /nix/store/shn5d1kpc4by84279fj532wgsidzz15v-unit-dbus.service.drv
  /nix/store/bf9g1n7x96y5fin5ani8n58s9a7mxhlv-user-units.drv
  /nix/store/gk3l7jfzz55mxv5j25zc8s7zr42fxvkk-etc-pam-environment.drv
  /nix/store/jyssg3byhnp32g1sgl2sqyk6f329n6pm-man-cache.drv
  /nix/store/nqbjbq8crrn8n6vb4p35gqq9b6hqxq4r-etc-man_db.conf.drv
  /nix/store/zj2lf1mk8ii2904y385021xw47z3w5wg-system-shutdown.drv
  /nix/store/mzkscbkwm4kll2wxf4glrcmlnbrhcp3b-etc.drv
  /nix/store/s2dbdfwgyv03m89dlyr40z5bkh9n71ix-nixos-system-athenaos-23.11.3409.d7f206b723e4.drv
building '/nix/store/3j36k7vz9hiw0bn2knar530p62l89y42-system-path.drv'...
building '/nix/store/jyssg3byhnp32g1sgl2sqyk6f329n6pm-man-cache.drv'...
building '/nix/store/dfjbcwamj7dns77m69xp0xqrag0jhy6f-reflection_by_yuumei-d8sqdu2.jpg.drv'...
warning: collision between `/nix/store/kjrhn5rnq96q1daa8ddkgvrd71vckyl3-caja-1.26.3/bin/caja' and `/nix/store/f0xanbgknrxl6fxxadwhcz7lmpbmy26x-caja-with-extensions-1.26.3/bin/caja'

trying https://orig00.deviantart.net/0054/f/2015/129/b/9/reflection_by_yuumei-d8sqdu2.jpg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
created 20668 symlinks in user environment
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 2119k  100 2119k    0     0  1599k      0  0:00:01  0:00:01 --:--:-- 1599k
building '/nix/store/syqll0r21q35w2ch35xbz6qc20yydk58-bg.patch.drv'...
gtk-update-icon-cache: Cache file created successfully.
building '/nix/store/dx04jfp285q525pb78jpggh1032klmxp-gnome-shell-45.3.drv'...
gtk-update-icon-cache: Cache file created successfully.
gtk-update-icon-cache: Cache file created successfully.
building '/nix/store/fsnwf76svz1059gzyp8086l1gj01x1la-X-Restart-Triggers-polkit.drv'...
building '/nix/store/sv27bxhjpiqil1786b0vvchld5j479nn-dbus-1.drv'...
building '/nix/store/gk3l7jfzz55mxv5j25zc8s7zr42fxvkk-etc-pam-environment.drv'...
building '/nix/store/fsvg01g0zvw8kkx9i9b2ivzmnc9kx9gm-set-environment.drv'...
building '/nix/store/p7a774pf42hha92hfqdbp07q80hz6r78-unit-accounts-daemon.service.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/fmzpnzkdnbznpnq22rgybwipmwb4r9ha-gnome-shell-45.3.tar.xz
source root is gnome-shell-45.3
setting SOURCE_DATE_EPOCH to timestamp 1704616904 of file gnome-shell-45.3/data/theme/gnome-shell-light.css
Running phase: patchPhase
applying patch /nix/store/pi3m8niz8c9hpyhbx7j5yn5f7mk8i9sk-fix-paths.patch
patching file data/org.gnome.Shell-disable-extensions.service
patching file js/ui/extensionDownloader.js
Hunk #1 succeeded at 116 (offset 6 lines).
Hunk #2 succeeded at 138 (offset 6 lines).
patching file js/ui/status/keyboard.js
Hunk #1 succeeded at 1103 (offset 11 lines).
patching file subprojects/extensions-tool/src/command-install.c
patching file subprojects/extensions-tool/src/command-pack.c
applying patch /nix/store/lvcbvgyzbw7lmiv7alrncl9md3nvbidd-shew-gir-path.patch
patching file subprojects/shew/src/meson.build
applying patch /nix/store/ywlajd02glm62sjbs3mb4ld06lbgpbkj-wrap-services.patch
patching file js/dbusServices/dbus-service.in
patching file js/dbusServices/dbus-service.service.in
patching file js/dbusServices/meson.build
Hunk #2 succeeded at 14 (offset -5 lines).
applying patch /nix/store/s6xymj47ad4dchcjfd0zywrgzyaq9rg1-greeter-logo-size.patch
patching file js/gdm/loginDialog.js
applying patch /nix/store/xjfym9hzz5yxhszcivryb9ykcg0lvvfn-0001-gdm-Work-around-failing-fingerprint-auth.patch
patching file js/gdm/util.js
Hunk #1 succeeded at 118 (offset -39 lines).
Hunk #2 succeeded at 530 (offset -14 lines).
Hunk #3 succeeded at 624 (offset -5 lines).
Hunk #4 succeeded at 690 (offset -5 lines).
applying patch /nix/store/ww97lrma7bdph22ina5a1apbixhk2p2r-bg.patch
patching file data/theme/gnome-shell-sass/widgets/_login-lock.scss
Hunk #1 FAILED at 15.
1 out of 1 hunk FAILED -- saving rejects to file data/theme/gnome-shell-sass/widgets/_login-lock.scss.rej
building '/nix/store/kkiwf5jx2wawq4l9qqipj17493vfl3j7-X-Restart-Triggers-dbus.drv'...
building '/nix/store/1ncfy6q26vy6hfp9ym02h1j4j8lmy4mf-etc-fish-nixos-env-preinit.fish.drv'...
building '/nix/store/86x53a8i3jjidgaw7n4b0yyfx184kbin-etc-profile.drv'...
building '/nix/store/4xbwa0q5asw8481d6ygpn97dpjh8adaz-unit-polkit.service.drv'...
error: builder for '/nix/store/dx04jfp285q525pb78jpggh1032klmxp-gnome-shell-45.3.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/3nab2p5bzxj0ddhdsxvx8vrgyrwbi906-system-generators.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mzkscbkwm4kll2wxf4glrcmlnbrhcp3b-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/s2dbdfwgyv03m89dlyr40z5bkh9n71ix-nixos-system-athenaos-23.11.3409.d7f206b723e4.drv' failed to build

Is there a way to make it working also for the latest GDM (GNOME Shell) version?