feat(greeter): add themed greetd login screen

- Add an AstalGreet login UI with PAM messages, reboot and shutdown.

- Run it under cage via start-greeter.sh and start a uwsm-managed Hyprland session.

- Include install script, polkit rule, fallback theme and README.
This commit is contained in:
pascalyazid committed 2026-11-27 18:55:33 +01:00
1 parent 8aea20ea9f
commit a1cea0e3be
5 files changed
+759

No files matched your search

+120
View File
@@ -0,0 +1,120 @@
# AGS greeter for greetd
A small AGS (GTK4) login UI that reuses this shell's pywal theme, wired to
greetd through [AstalGreet](https://aylur.github.io/libastal/greet/).
## How it fits together
```
greetd ──exec──> start-greeter.sh ──> cage ──> dbus-run-session ──> ags run greeter.tsx
^ │
└──────────────── AstalGreet.Greeter (GREETD_SOCK) <─────────────────────┘
```
AstalGreet is only the greetd IPC client; a compositor still has to host the
GTK window. Cage is used because it is a tiny kiosk compositor. Cage does not
support `wlr-layer-shell`, so the greeter is a plain `Gtk.ApplicationWindow`
(which cage maximizes) instead of an `Astal.Window`.
## Requirements
- `greetd` (already installed)
- `libastal-greetd` (already installed, provides `AstalGreet-0.1`)
- `ags` (already installed)
- `cage` — `pacman -S cage`
- `dart-sass` (already installed, used to compile the theme)
- a `greeter` user in the `video` group (already present)
## Install
```sh
sudo pacman -S cage
sudo ./greeter/install.sh
```
The script:
- copies `greeter.tsx`, `style.scss`, and `start-greeter.sh` to
`/etc/greetd/ags` (the `greeter` user cannot read `/home/pascal`, which is
`0700`)
- creates `/var/lib/greetd/{run,.cache}` owned by `greeter`
- compiles a fallback theme and seeds the current pywal theme/wallpaper
- installs `/etc/polkit-1/rules.d/49-greetd-greeter.rules` so the `greeter`
user can reboot/power off from the login screen
- writes `/etc/greetd/config.toml` (backup at `config.toml.bak`)
**Keep a TTY available (Ctrl+Alt+F2)** before restarting greetd so you can
recover if the greeter fails.
```sh
sudo systemctl restart greetd
```
## Theming
`theme.ts` now calls `exportGreeterTheme()` on startup and after every
`setTheme()`:
- `greeter/style.scss` is compiled with the current `wal` palette to
`/var/tmp/ags-greeter/greeter.css`
- `~/.cache/current_wallpaper.jpg` is copied to
`/var/tmp/ags-greeter/wallpaper.jpg`
`/var/tmp` is used because it survives reboots and is readable by the
`greeter` user. `/tmp` is empty at boot (the greeter runs before login) and
`~/.cache/wal` is unreadable by `greeter`.
If the exported files do not exist yet, the greeter uses
`/etc/greetd/ags/fallback.css`, then an inline fallback.
## Preview
In a running Hyprland session:
```sh
ags run ./greeter/greeter.tsx
```
This shows the real UI, but pressing "Log in" reports that the greeter must be
started by greetd (there is no `GREETD_SOCK` in your session).
## Login messages and power buttons
PAM info/error messages are shown in the card. greetd often reports only a
result code (for example `authenticate: AUTH_ERR`), so the greeter maps those
to readable text such as "Incorrect password. Please try again."
The card also has reboot and shut-down buttons. They call
`/usr/bin/systemctl`; the polkit rule installed by `install.sh` allows the
`greeter` user to perform those two actions without an authentication agent.
## Debugging
`greetd` prefixes its command with `exec`, so the chain lives in
`start-greeter.sh`. Its output (cage/AGS) is logged to:
```sh
cat /tmp/greeter.log
```
If greetd hits `start-limit-hit`, reset it after fixing:
```sh
sudo systemctl reset-failed greetd
sudo systemctl start greetd
```
## Notes / limitations
- `cage -m last` (in `start-greeter.sh`) puts the greeter on one monitor only.
Use `-m extend` to span all monitors, or switch to a layer-shell compositor
(sway/Hyprland) if you want per-monitor greeter windows.
- After a successful login the greeter starts
`/usr/bin/uwsm start -e -D Hyprland hyprland.desktop` (the same command as
`/usr/share/wayland-sessions/hyprland-uwsm.desktop`). No greetd-specific
uwsm configuration is needed; `~/.config/uwsm/env*` is still read from your
home when uwsm starts the user session. If you stop using uwsm, replace
`SESSION_CMD` in `greeter.tsx` with `["/usr/bin/start-hyprland"]`.
- The username field defaults to the user recorded in
`/etc/greetd/ags/default-user`; it can be edited before logging in.
- The greeter does not implement reboot/shutdown buttons yet.