Subject: [bug#75449] [PATCH v2] gnu: Add pi-greeter.

From: [email-masked]
Date: Mon, 20 Jan 2025 10:45:14 +0800

From: Feng Shu <[email-masked]>

* gnu/packages/display-managers.scm (pi-greeter): New variable.

Change-Id: I77f77818e15d950cfda0c1dd3bb41e164516cdb7
---
 gnu/packages/display-managers.scm | 89 +++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 0b818193cc..8bee2aaa40 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -699,6 +699,95 @@ (define* (customize-lightdm-tiny-greeter #:key name session
                     (("font: .*px")
                      (string-append "font: " #$fontsize "px"))))))))))))
 
+(define-public pi-greeter
+  (let ((commit "4acc867b4807000fbd31bafbd33fe35ef1eda39d")
+        (revision "0"))
+    (package
+      (name "pi-greeter")
+      ;; No git release tag, get version from debian/changelog file.
+      (version (git-version "0.25" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/raspberrypi-ui/pi-greeter.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0g67211zk57k32wphika72vr3sxiqp0j0z5d7pr9gapddslf4xay"))))
+      (build-system glib-or-gtk-build-system)
+      (arguments
+       (list
+        #:configure-flags
+        #~(list
+           ;; Put the binary under /bin rather than /sbin, so that it gets
+           ;; wrapped by the glib-or-gtk-wrap phase.
+           (string-append "--sbindir=" #$output "/bin")
+           (string-append "--enable-libindicator")
+           (string-append "--enable-indicator-services"))
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'customize-default-config-path
+              (lambda* (#:key inputs #:allow-other-keys)
+                (substitute* "configure.ac"
+                  (("INDICATOR_PKG=indicator-")
+                   "INDICATOR_PKG=indicator3-"))
+                (substitute* "src/Makefile.am"
+                  ;; Have the default config directory sourced from
+                  ;; /etc/lightdm/pi-greeter.conf, which is where the
+                  ;; lightdm service writes it.
+                  (("\\$\\(sysconfdir)/lightdm/pi-greeter.conf")
+                   "/etc/lightdm/pi-greeter.conf"))
+                (substitute* "src/pi-greeter.c"
+                  (("/usr/lib/at-spi2-core/at-spi-bus-launcher")
+                   (search-input-file inputs "/libexec/at-spi-bus-launcher")))))
+            (add-after 'glib-or-gtk-wrap 'custom-wrap
+              (lambda _
+                (wrap-script (string-append #$output "/bin/pi-greeter")
+                  ;; Wrap GDK_PIXBUF_MODULE_FILE, so that the SVG loader is
+                  ;; available at all times even outside of profiles, such as
+                  ;; when used in the lightdm-service-type.  Otherwise, it
+                  ;; wouldn't be able to display its own icons.
+                  `("GDK_PIXBUF_MODULE_FILE" =
+                    (,(string-append
+                       #$output
+                       "/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache")))
+                  `("XDG_DATA_DIRS" ":" prefix
+                    (,(string-append "/run/current-system/profile/share:"
+                                     (getenv "XDG_DATA_DIRS"))))
+                  '("XCURSOR_PATH" ":" prefix
+                    ("/run/current-system/profile/share/icons")))))
+            (add-after 'install 'fix-.desktop-file
+              (lambda _
+                (substitute* (string-append
+                              #$output
+                              "/share/xgreeters/pi-greeter.desktop")
+                  (("Exec=pi-greeter")
+                   (string-append "Exec="
+                                  (string-append
+                                   #$output "/bin/pi-greeter")))))))))
+      (native-inputs
+       (list autoconf
+             automake
+             gnome-common
+             intltool
+             pkg-config
+             which))
+      (inputs
+       (list at-spi2-core
+             gtk+
+             gtk-layer-shell
+             guile-3.0
+             gobject-introspection
+             libindicator
+             lightdm))
+      (synopsis "GTK greeter for Raspberry Pi")
+      (home-page "https://github.com/raspberrypi-ui/pi-greeter")
+      (description "A simple GTK-based greeter for the Raspbian LXDE desktop.
+This greeter have no session menu, so user should set user-session option in
+lightdm config file.")
+      (license license:gpl2+))))
+
 (define-public slim
   (package
     (name "slim")
-- 
2.45.2