# Handoff: start here Rust/niri port of ladybug-me/caelestia-kde (a0bc311). Read this, then `docs/AUDIT.md`. Older notes: `docs/NEXT-SESSION.md`. ## The rule Port the original files 1:1. Do not invent designs, sizes, colours, spacing, animations or behaviour: read the QML/C++ and translate it. If something is KDE-only, replace only that part with the niri equivalent and say so. ## Do not touch or "fix" toward the original Nexus Shortcuts tab (caelestia-binds.kdl), Window Rules page (caelestia-windowrules.kdl), `crates/core/src/niri.rs`, bar defaults (dock, showDesktop, screencapture, keepawake off; `bar.dodgeWindows` rows gone; white distro logo; audioIncrement 0.05), removed KDE stuff (updates, plugins, KDE/KWin rows), Quick Share, Caelestia mode, `crates/shell/src/fuzz.rs` (only its sample data may follow a struct change). The user has opened up `assets/niri/*` for default binds and `scripts/` for the installer. Niri additions are fine when the user asks or KDE did the job; label them in `docs/AUDIT.md`. ## Setup - Original: clone https://github.com/ladybug-me/caelestia-kde read-only into the scratchpad and check out a0bc311. The clone takes several minutes and goes in a session scratchpad, so make a new one, in the background. Never use `gh`; GitHub account is suspended. - Remote `origin` = `forgejo:astar76/caelestia-niri.git`. Commit each area and push to main. - Build: `cargo build --release`, about 2 minutes. Run it in the background. - After touching config or Nexus: `cargo test --release`, then `cargo test --release -p caelestia-shell every_setting -- --ignored --nocapture` (about 6 minutes, wants 0 crashed). Run the fuzz and tests with a stand-in `secret-tool` on PATH: Nexus reads the keyring. - Restart the live shell, telling the user first, every time: `pkill -x caelestia-shell; sleep 0.5; setsid nohup ./target/release/caelestia-shell >/tmp/shell.log 2>&1 < /dev/null & disown` - The user runs this shell live on niri with DMS stopped; keep DMS closed. Two 1600x900 monitors, DP-1 and HDMI-A-1. - Snapshot: `./target/release/caelestia-shell --snapshot out.png --size 1600x900 [--dashboard --tab N] [--nexus PAGE --sub SUB] [--launcher] [--background]`. Test config: `XDG_CONFIG_HOME=` with its own `caelestia/shell.json`. - Nested niri needs a short runtime dir (`/run/user/1000/cn`), plus `PIPEWIRE_RUNTIME_DIR=/run/user/1000` and `PULSE_RUNTIME_PATH=/run/user/1000/pulse` for audio. `CAELESTIA_PROF=1` prints timings. - `caelestia shell toaster info|success|warn|error <message> <icon>`, `notifs clear|toggleDnd|enableDnd|disableDnd|mute <app>|unmute <app>`, `lock preview`. - `caelestia shell drawers toggle dashboard` and `caelestia shell dashboard tab N` drive panels (binary in target/release). ## Traps - Never `pkill -f` a pattern: it matches your own shell and kills the command (exit 144). Use `pkill -x` or a PID. - A `while pgrep -f ...` waiter matches itself and never ends. - `grep caelestia-shell` on plain `top` misses it: the name is truncated. Use `top -c -w 200`. - Do not script edits to `~/.config/caelestia/shell.json`. It was refused. It holds a `general.apps.audio` boolean, which logs "ignoring" harmlessly; the user can delete that line. `merge_typed` drops only the bad key. - `~/.config/niri/gamemode.kdl` is written by the user's `dms-gamemode`, not only by us. - Settings rows come from `assets/nexus/pages.json`; change them in `add_niri_pages` in `nexus/mod.rs`. - Unknown bar ids size to 0 in `item_size`. - Qt line height is ceil(ascent)+ceil(descent) (`Painter::line_height`); `measure` is a 1.25em box. - Report honestly: say what was only snapshot-tested and what was tested live. - Size tokens are functions now (`PADDING_SMALL()`, `SPACING_MEDIUM()`, `ROUND_XL()`), because they follow `appearance.*.scale`. They cannot go in a `const`. - The screen a thing is on matters: use `Shared::bar_position(output)` or `Screen::bar_edge`, never `cfg.bar.position`. - A background child that outlives the shell can break the machine: use `services::helper` (it dies with the shell). An `exec` restart keeps the pid, so that alone is not enough. 64 orphaned `pactl subscribe` once blocked every audio app. - The background layer reuses its last frame and restores only marked rects: anything painted there must go through `Bg::mark`, or it leaves ghosts and its alpha stacks up. - A Nexus page built at runtime goes in `livepage::is_live` and `expand`. If it reads none of the popout data, add it to the exclusions in `wants_live`, or it spawns `pactl`, `nmcli` and `bluetoothctl` on a timer. Changes to `live:` keys arrive in `take_live`. - In the installer's bash, `((x))` that evaluates to 0 trips `set -e`: use `x=$(( ))` or `if ((x))`. - Snapshots do not wait for background reads (`syslook::look`, `rpc::shown_key`, desktop icons), so check those on a running shell. ## Where things stand Everything is pushed to origin main and the shell runs live on the user's real config, by hand: see the state section below. Last checks: 69 tests passing, 3 known build warnings (`layer`, `backend`/`candidate`/`offset`, `refresh`), fuzz 871 tried, 0 crashed. Done in the last session, each with a section in `docs/AUDIT.md`: the stuck volume OSD, Notifications (service, popups, sidebar, pages), the toaster, the Dino game (Caelestia mode removed), the lock screen, Displays, Timers, Session, Utilities, Apps, Services, Language, About, Startup, Storage, Accessibility. The preview passed on 2026-11-05: the user's real password and keyboard unlocked it, `lock-proved` is written, and the shell's own lock is now their real one, idle lock included. The real session lock then ran on their two monitors the same day: locked at 03:49:09, unlocked with their password at 03:49:22, no crash. Recovery after a lost connection is tested in a nested niri only. History: the first version of the preview crashed the shell with the real session lock up, its 45 second unlock died with it, and the user had to restart niri. Their password was refused by our own bug: after `pam_authenticate` we called `pam_acct_mgmt`, and the `swaylock` service has no account section, so `/etc/pam.d/other` denied it (`pam_warn(swaylock:account)` in the journal). Fixed: only authenticate, as swaylock does. 8 s later niri dropped the shell (`error in client communication`, meaning the client fell behind). The lock repainted on every pointer event; that fits the logs, but a nested stall test did not reproduce the drop, so that cause is not proven. Since then the preview is an ordinary overlay with no session lock (Escape leaves, gone after 90 s), and `lock_screen` runs swaylock unless `~/.local/state/caelestia/lock-proved` exists. Keep that gate: deleting the file goes back to swaylock. Never write a watchdog that lives inside the process it guards. Before the switch, on 2026-11-05, these were not live: Print and every default bind (their Print runs DMS's command, `~/.config/niri/config.kdl` line 277, and does nothing), Mod+G, `xray false` for blur (their config has a hand-added copy; remove it after, backup `config.kdl.bak-blur-caelestia`), `caelestia-cursor.kdl`, and `caelestia-outputs.kdl`, so Displays' kept settings do not survive a niri restart until then: their `dms/outputs.kdl` is what loads. They said to change Print in the installer's dotfiles, not in their own config. The include comes last and overrides their Print. ## State at the end of 2026-11-05 - **The user switched.** DMS and `dms-gamemode` are stopped and out of `niri.service.wants`, still installed. `~/.local/bin/caelestia-shell` runs live on the real config, and `spawn-at-startup` starts it at login. A real login has not been tried. - `config.kdl` no longer names DMS. `caelestia-outputs.kdl` and `caelestia-cursor.kdl` came from DMS's files, and `caelestia-recommended.kdl` holds their layout, input and animations. The `dms/` folder is still on disk, unused. - The way back: `caelestia-back-to-dms` from a text console, backup in `~/.local/share/caelestia-dms-backup`. It does not undo theme files written for other apps. - Packages still missing, needing sudo: `xdg-desktop-portal-gnome`, `gnome-keyring`, `qt6ct`, `udiskie`. The PAM file `caelestia-lock` is not installed either, so the lock uses the `swaylock` service. - The new lock is proved and is their real lock: `~/.local/state/caelestia/lock-proved`. swayidle locks at 10 minutes. - The `general.apps.audio: false` warning at every start stays until they pick an Audio app on the Apps page. - Restart the live shell from niri, telling them first, so it does not inherit a tool's environment: `pkill -x caelestia-shell`, then `niri msg action spawn-sh -- 'exec "$HOME/.local/bin/caelestia-shell" >"$HOME/.cache/caelestia-shell.log" 2>&1'`. Install with `install -m755 target/release/caelestia{,-shell} ~/.local/bin/`. ## 0.1.0 and the clean install v0.1.0 is on Astar Hub's Releases page. The user is wiping DMS, niri and Caelestia's configs with `clean-wipe.sh`, kept out of git, then running `./install.sh` from a text console. That is the first real clean install: nothing has proved it end to end. After it: monitors have no saved arrangement until set in Displays, and the lock is swaylock until `caelestia shell lock preview` passes. ## After the clean install (2026-11-05) The first real clean install, from `clean-wipe.sh`, passed: no failed packages, login starts the shell, portals run. The login sync missed at install because no scheme existed yet: `05-extras.sh` now sets the default wallpaper first. Still to do by hand: monitors in Displays, as niri's defaults swapped them and chose 60 Hz, and `caelestia shell lock preview`, because `lock-proved` went in the wipe. ## Pick up here `docs/PLAN.md` has the DMS audit: what a clean install now gets, what is left on the machine, and the binds to choose. The user means to wipe Arch of DMS, so the repo alone has to give a whole desktop. They will give their default binds and config changes before that. Work this list top to bottom. Each item ends with tests, the fuzz if config or Nexus changed, a commit and a push. 1. AI Assistant: removed at the user's request, 2026-11-05. Do not port it. 2. **Settings left to prove live.** Clicking the new pages (Apps menus, App info, weather search, Startup, Storage, Accessibility, Focus, muted apps), the quick toggle wheel, Timers end to end, Displays' drag and Apply, sounds, inline reply, real notification images. The user said to test on their system: see "Testing settings for real" below. Anything needing the pointer needs them to agree first and the target checked in the same command. 3. **The installer and system setup: the list below.** Then the user's switch from DMS, with them present, each step on their go-ahead: `./install.sh`, disable DMS, stop `dms-gamemode`. 4. **niri defaults:** `docs/NIRI-DEFAULTS.md` has what a bare niri lacks and proposed settings, none applied. The biggest gap is input: there is no way to set keyboard layout, repeat, mouse speed or touchpad without editing KDL. The user's decision: these go in the existing **Connected devices** tab (the `bluetooth` page), not a new page. 5. Things only the real setup can prove, after the switch: System look on a real GTK and Qt app and niri's cursor; desktop icons on the real desktop, with Paste, Cut, the real clipboard and auto arrange; capture's satty save, clipboard, notification buttons and Pause; hover zones on a moved bar; Discord presence against real Vesktop, Discord or arRPC, and Steam detection; Wi-Fi, Bluetooth pairing and volume rows; game mode with music playing; idle lock firing by itself; lock recovery after a lost connection; the user's autostart on a real login. 6. Notifications, what is left: `shouldPush` under a popout, popup removal slide, `notifs.focusCalendar`, Battery warnings (`BatteryMonitor` levels), toasts' stack sliding when one closes, ExtraIndicator, bold and italics in bodies (the words and links are kept), the Notification sound picker on Sound effects, Volume tick on sliders. 7. Lock screen, what is left: password shapes do not morph or animate out; the error text has no flash; the keyboard layout button on the portrait layout; fingerprint and Howdy; the `lock.wallpaperPath` row; Switch User uses `dm-tool`, which SDDM does not have. (Done in S007, except fingerprint, Howdy and Switch User, left out by D-009.) 8. Ported nowhere yet, needs `caelestia-color`: Smart color scheme and Color intensity, hidden until then. 9. Desktop icons, what is left: groups, large folders, arrow keys, Shift ranges, dragging to other apps and between monitors, the live drop preview, Pin to dock, the bundled monochrome icon set (a git submodule of the original). 10. Panels leftovers. Popouts not ported: Greeter (slideshow media, `bar.popouts.greeter` off by default), keyboard layouts, Night Light (see NIRI-DEFAULTS), Privacy (needs PipeWire stream tracking), DockHover (niri has no window capture). Updates and Github are left out on purpose. In Notes: audio recording and playback, file pickers. Dead keys with nothing to attach to: `sidebar.defaultTab`, `ai.showNews`. `ai.showCaelestiaMode` and BarScreenCapture `show*` are read nowhere in the original outside Nexus. 11. Settings pages left: Network's Add VPN and provider rows, IPv4 editing; Calendar sources (the clock popout's agenda needs `scripts/calendar_events.py` ported); the launcher's web search and its engine row; Shell language (translations); app icons in Apps' lists; File Types. Check pinned, favourites and hidden have clickable list editors. `pages.json` is older than a0bc311: compare `PageDictionary.qml` and each page before trusting it, as Displays, Startup, Storage, Accessibility and Calendar were missing. 12. Known missing: Terminal tab, video wallpapers (the Video Wallpapers rows have no reader), widget copy and paste, Escape leaving widget edit mode, Weather and Notes tab audits, News tab, config paths into the niri folder with migration, media key rebinding. 13. A real clean install: a VM or throwaway user. Tested so far on a pty in a temporary HOME with stand-in `pacman`, `sudo` and `systemctl`, then booted in a nested niri. Fedora and Debian package names are unchecked. Non-xray blur's GPU cost is unmeasured. ### The installer: what has to change None of this is done. The installer has not been rerun since the notifications, lock and Displays work. **The user's decision (2026-11-05): what was found missing belongs in the installer, as options.** Each is a tick on the installer's checklist, on by default where the shell needs it, so nothing is forced and nothing is left for the user to find out later. Each option should also show in Nexus, saying whether it is installed, where a page fits: devices and input in Connected devices. Details are in `docs/NIRI-DEFAULTS.md`. The options: - Screen sharing and file pickers: `xdg-desktop-portal-gnome`, `niri-portals.conf`. - Keyring: `gnome-keyring`, unlocked at login through SDDM's PAM file, with sudo, asked first. - Qt theming: `qt6ct` and `QT_QPA_PLATFORMTHEME`. - Automount: `udiskie`, or the shell mounting on insert. - Night light: `wlsunset` (S012 picked it; the shell starts it itself, so no autostart entry). Add it to the package lists (Arch `extra`; check the Fedora and Debian names). - Video wallpapers: `mpvpaper` (S014; AUR only on Arch, so it needs the AUR helper; check Fedora and Debian) and `ffmpeg` for the frame that gives a video its colours. Optional: without mpvpaper the shell shows the frame and says so in a toast. - X11 tray icons: `xembedsniproxy`. - Clipboard: `wl-clip-persist` and `cliphist store`. - Lock: the PAM file, then the preview. - Recommended niri settings: `caelestia-recommended.kdl`. - `02-build-shell.sh` copies `assets/`, which now holds 17 MB of `sounds/` and `fonts/`: check the data dir gets them and the shell finds them through `CAELESTIA_DATA_DIR`. A missing `sounds/` or `images/dino*` fails silently. - PAM: building now links `libpam`. Arch has it in `pam`; add `libpam0g-dev` to Debian's and `pam-devel` to Fedora's build lists. Install `/etc/pam.d/caelestia-lock` (`auth include login`, no account lines: without an account section PAM falls to `other`, which is why `pam_acct_mgmt` must stay out), with sudo, asking first. `auth.rs` already prefers it. - swaylock stays in the package lists until a preview has passed. A fresh install starts on swaylock and should tell the user to run `caelestia shell lock preview`, or offer it at the end. - `03-niri.sh` must carry `caelestia-outputs.kdl`'s include, which `assets/niri/caelestia.kdl` has. Their `dms/outputs.kdl` also defines both monitors: remove or order that include at the switch, or Displays' settings lose. - Add to the package lists: `pipewire` provides `pw-play` and `pw-dump` on Arch, check Fedora and Debian (`pipewire-utils`, `pipewire-bin`). `util-linux` for `lsblk`. Optional: `udiskie`, `wlsunset`, `qt6ct`, `xdg-desktop-portal-gnome` and `gnome-keyring` are listed but missing on this machine: find out why the old install skipped them. - Portals: write `niri-portals.conf`. Keyring: PAM line for SDDM, with sudo and asking first. See NIRI-DEFAULTS. - Spawn `wl-clip-persist`, `cliphist store` and `xembedsniproxy` if the user wants them: check what `caelestia.kdl` already does. - The installer's README and summary still describe swaylock as the lock. Not a bug to chase unless it comes back: capture Space closing the overlay was not reproduced in 114 tries (24 live, 90 nested) with every key and every close logged, and `Capture::key` has no path from Space to Close. `wtype` sends keycode 1, Escape on a normal keymap, so a race on its keymap is the likely cause, unproven. Seen on a real keyboard, log `press_key` and `cap_close`. Other loose ends, not chased: `assets/images/wallpaper.webp` was once found deleted from the working tree, cause unknown, so check `git status` before committing. The tray's `>` chevron went missing once after quick restarts. Stat pills with music cost 34% of a core. Hardware encoding fails here even in plain `ffmpeg` with `h264_vaapi`, so recordings use the CPU. A DMS-era `dms-gamemode` still runs with DMS stopped. ## Testing without touching the user's things This session's rules, learned the hard way: - Pointer: `tools/vptr` (build it, usage at the top of its source). `wtype` for keys. Never send a key or click unless the target is confirmed there, in the same command: a drawer seen a minute ago can be gone. A live try once put wheel events and two clicks in the user's terminal that way: a stray Escape hid Mulberry to its tray (its tray entry's `Activate` brought it back). - Never `pkill -x` anything the user may have open, such as kitty: stop stand-ins by PID. `pkill -x caelestia-shell` is fine, told first. - Live test shell: `XDG_CONFIG_HOME=<copy>`, `XDG_STATE_HOME=<copy>`, with `paths.screenshotsDir` and `paths.recordingsDir` in the scratchpad, and `capture.json` with `copy` and `notify` off. Add `HOME=<dir>` and `XDG_DATA_HOME=<dir>` when a test writes system look or desktop files. - Stand-ins on `PATH`: `secret-tool`, `gsettings` (log `set`, pass `get` to the real one), `gio`, `xdg-open`, `wl-copy`, `wl-paste`, `cliphist`, `arrpc` (a Python socket doing Discord's handshake works). Nested niri for anything that hits the real clipboard, such as window capture, and for an empty desktop. - Nested niri: `XDG_RUNTIME_DIR=/run/user/1000/<short>`, `WAYLAND_DISPLAY=/run/user/1000/wayland-1` to start it, then `WAYLAND_DISPLAY=wayland-1` and `NIRI_SOCKET=<its socket>` for clients. Its window size changes after it opens: read it from a `grim` shot, and pass it as `VPW`, `VPH`. Find its shell by `XDG_RUNTIME_DIR` in `/proc/<pid>/environ`. A test shell there reaches PipeWire and pipewire-pulse only with `PIPEWIRE_RUNTIME_DIR=/run/user/1000 PULSE_RUNTIME_PATH=/run/user/1000/pulse` (else the visualiser, volume and privacy indicator see nothing). A popout opened by IPC closes as soon as the host pointer moves over the nested window: hover its item with `vptr` instead. - Prove a setting by rendering it: `--snapshot` with it changed against a baseline, measured against the clock and visualiser's noise. A name match in the code passed rows that did nothing. - Nested niri stops taking input and frames while its window is hidden: `wtype` hangs and `--snapshot` is the better check. A nested shell's swayidle runs real swaylock after 10 idle minutes, and `wtype` then types into PAM as the user: set `lock.idleLock`, `idleScreenOff` and `idleSuspend` to 0 in the test config. `grim` cannot capture a locked session. - The lock's logic (`locktest <text>`, `locktest cut`, test build only; there is no `locktest stall`: stop the shell with `kill -STOP` for a stall; a test state folder needs a `lock-proved` file): build with `CAELESTIA_LOCK_TEST_PASSWORD=x cargo build --release -p caelestia-shell`, copy the binary out, then rebuild without it (`touch crates/shell/src/auth.rs`). Only that build has `caelestia shell locktest <text>`. `--snapshot out.png --lock [--typed] [--wrong] [--frames N]` draws it. Notifications need the name `org.freedesktop.Notifications`: a nested test shell gets it on a private bus, `dbus-daemon --session --print-address --fork`. `--popups [--expand]` draws popups and toasts. - Testing settings for real without the pointer: stop the live shell, run the build on the real session with `XDG_CONFIG_HOME` and `XDG_STATE_HOME` on copies and `lock.idle*` at 0, change the copy, `caelestia shell reload`, send real `notify-send` or `toaster`, and compare `grim -o HDMI-A-1` in zones. Size the zones for 900 tall, not a nested window. Restart the live shell in a `finally`. - Dead settings: for each `shell:` key in `pages.json`, grep the snake-case leaf after a dot in `crates/`. A row that is visible with no reader does nothing. - Also: `CAELESTIA_PROF=1` prints timings and `dirty wl.rs:LINE`. `caelestia shell popout weather|media|performance|shortcuts|notes|clock|kblayout|nightlight|privacy|greeter|menu|close`. `caelestia shell capture [region|window|screen|scroll|text|record|gif|stop]`, `capture now screen|window`. `caelestia shell nexus sub <Page>`, twice if the window was closed. `caelestia shell gameMode toggle|enable|disable`. Badges need a live D-Bus sender (Python `gi`). The user plans to make this their daily setup: prefer finishing and hardening over new features. The lock is the shell's own, on ext-session-lock (`lockscreen.rs`, `auth.rs`, `lock_screen` in `wl.rs`), behind swaylock until proved. Idle uses swayidle: `sync_idle`, times in `lock.idle*`. `services::polkit_agent` starts an agent.