Skip to main content

niri-desktop-continuity

ci PyPI license

Reboot, log in, and your niri desktop comes back. Windows reopen on their workspaces in their column order, Claude Code and Pi sessions resume by id, and anything that cannot be reopened safely is reported, never guessed.

Offline preview of a fabricated demo desktop: a project workspace with Claude Code and Pi sessions, a dev server and an X11 IDE, then a browser workspace; each tile says whether it reopens after a reboot

The offline preview page for a fabricated demo desktop (not anyone's real one): the first two of its five workspaces, 23 windows in all. Every tile says how it comes back after a reboot, or why it will not.

Status

This branch brings every application back again. It is the 0.1.2 restorer with its three known defects fixed: each saved app instance is launched once (no second launch after a wait), only new windows of that app are adopted (never an unrelated window), and coding agents are never replayed from their command line. Apps start from their own menu entry, so wrappers, AppImages and sign-in or deep-link URLs are handled the way you launch them. Saved column widths now account for window borders, a fix carried over from the strict line. The strict controlled-Ghostty candidate that preceded it no longer drives restore; its reconstruction and disposition commands remain. Offline tests pass, and a real login restore of a mixed desktop (Claude Code and Pi sessions, browsers, notes and password-manager windows, shells and commands) placed 57 of 57 windows in 35 seconds with no failures.

Why

niri's scrolling columns make it easy to build a desktop that is worth keeping: a workspace per project, terminals running agents and dev servers, a browser and notes beside them. A reboot or a crash throws all of it away, and rebuilding it by hand, window by window and column by column, takes longer than the reboot did.

This small tool saves the shape of your desktop every 15 minutes and, at your next login, puts it back. From a real reboot of the maintainer's desktop:

  • 26 windows saved, 25 reopened at login in 49 seconds, every one on its saved workspace in its saved column order.
  • Claude Code and Pi sessions resumed by id.
  • Two sessions that could not be resumed came back as fresh sessions started from their handoff notes (declare), instead of replaying their opening prompts.
  • The one miss, an X11 app, was reported in the receipt, not guessed.

Quickstart

Requires Linux, niri and Python 3.11+, with Ghostty as your terminal. No runtime dependencies.

pipx install niri-desktop-continuity
# or: uv tool install niri-desktop-continuity

Every release is also on GitHub Releases with checksums; what changed is in the changelog.

Save your desktop and check what would come back:

niri-desktop-continuity capture    # save windows, workspaces and a reopen recipe per window
niri-desktop-continuity preview    # write an offline HTML map of the latest capture; open the printed path
niri-desktop-continuity restore    # dry run: the placement plan, as JSON; nothing is launched

Reopen it: automatically at every login, which is all most desktops need:

niri-desktop-continuity autostart --enable --keep-days 3  # capture every 15 min, keep 3 capture days, reopen at login
niri-desktop-continuity restore --apply      # by hand: reopen the latest capture now

At login the restore service runs restore --apply --at-login for you; it waits for Niri, and skips when the capture came from the same Niri instance. By hand you need restore --apply only when saved windows are gone while you stay logged in, for example after closing them by mistake, or to reopen an older capture by its digest. It launches each saved application that is not running and each saved terminal tab that is not open. A plain shell or command tab cannot be recognised as already open, so on a desktop where it still runs it opens a second time.

A session that cannot be resumed (for example, a Claude Code session started from inside another one, which keeps no transcript) is not reopened. If you would rather it came back as a fresh session, say so while it is still running:

niri-desktop-continuity declare --pid <pid> -- claude "Continue from docs/handoff.md"

<pid> is any process in that terminal (for example from pgrep -a claude). The declaration lives until the next reboot, applies only to that exact process, and declare --pid <pid> --clear removes it.

Check before you restart

preview writes a standalone HTML page and prints its path. Its After a reboot section lists every saved window: whether it reopens, as what, with the exact command and directory, or why it will not.

The "After a reboot" section of the preview for the same demo desktop: 21 of 23 reopen; an unregistered Claude session and an X11 IDE will not, each with its reason

Same fabricated demo desktop, first workspace's rows. restore prints the same plan as JSON.

How it works

Each capture reads niri's IPC and same-user process metadata, and records a private reopen recipe per window:

Kind How it comes back
app launched once per saved instance from its desktop entry; its new windows fill the saved places
claude Ghostty, running claude --resume <id> in the session's directory (Claude Code's session registry)
pi Ghostty, running Pi's own resume command (Pi's presence directory)
nodecode Ghostty, running the resume command the nodecode shell recorded for its session ($XDG_RUNTIME_DIR/nodecode/shells)
declared Ghostty, running the command you gave declare, or the session an agent announced with hook
command Ghostty, running its last command again (for example btop or npm run dev)
shell Ghostty, opened in the same directory
unknown not reopened, with the reason, for example xwayland-client or agent-session-unannounced

restore --apply takes one lock per compositor, then launches the groups one after another. An app group is every saved window of one process (for example six Brave windows): it is launched once, and new windows with that app's ID are adopted until the saved number arrived, they stop arriving, or the spawn timeout passes. An app that is already running is not launched again and its windows are not touched. Each saved Ghostty window is its own launch, with your normal Ghostty configuration. Adopted windows go to their saved workspaces and columns, with saved widths and floating positions, after any windows that were already open. Every run writes one receipt; exit 2 means some window did not come back.

Where apps launch from. First an entry in $XDG_CONFIG_HOME/niri-desktop-continuity/routes.json, then the desktop entry whose name or StartupWMClass equals the app ID, or whose program is the captured executable, then the captured command line without URL or deep-link operands. A second instance of the same app (for example a second browser profile) keeps its own command line, because one menu entry cannot tell two profiles apart. restore without --apply prints each window's route.

{"routes": {"brave-browser": {"argv": ["brave", "--profile-directory=Work"]}}}

Agent sessions. An agent comes back only through a session it announced. Claude Code and Pi are read directly. Any agent with session hooks announces itself with one hook line in its own settings, for example in Claude Code's settings.json under hooks.SessionStart: {"type": "command", "command": "niri-desktop-continuity hook claude"}. Codex takes the same command in ~/.codex/hooks.json (trust it once with /hooks; sessions in Codex's shared daemon cannot be tied to a tab, so use --no-daemon where a tab should come back). angelX has tool hooks only, so its tabs are refused until it can announce a session. Any other agent passes its own resume command: niri-desktop-continuity hook myagent -- myagent --resume {id}. A new session or thread switch replaces the record, so the newest session wins. Details: usage.

What it never does

  • Never closes a window, and never moves one that was open before the run. Reopened columns go after them.
  • Never launches an app twice in one run, and never adopts a window of another app.
  • Never replays what it cannot resume. A coding agent (Claude, Codex, Pi, angelX, Gemini, Aider and others) without an announced session is not relaunched from its command line, which would start the same work over. A captured sign-in URL or app:// deep link is never opened again.
  • Never guesses. An X11 window (niri reports only the xwayland-satellite bridge), an unresolvable AppImage mount or an unreadable process is reported with a reason, not launched.
  • Never runs anything at login unless you opt in. autostart --enable writes three systemd user units, --disable removes them. Nothing else installs a service or edits your configuration.
  • Never executes a discovered binary while capturing. Executables are hashed, not run.
  • Makes no network requests of its own. No telemetry, no daemon. The preview is static HTML with no scripts or remote assets, and no browser is launched for you.
  • Never reads terminal contents or browser profiles. Session ids come from Claude Code's session registry, Pi's presence files and nodecode's shell records. From a Claude Code transcript it takes only the session title, to tell apart windows of one terminal process.

Records stay private: 0700 directories and 0600 files under $XDG_STATE_HOME/niri-desktop-continuity (default ~/.local/state/niri-desktop-continuity, or --state-root <dir>). Window titles and session titles are redacted unless you capture --include-titles. Recipes still contain command lines and working directories, so treat captures and previews as private and do not publish them.

Honest limits

  • niri on Linux only. No other compositor or platform is planned. Alpha software.
  • Reopening is not restoring memory. Applications bring back their own content. Unsaved drafts, scrollback, shell state and the order of hidden tabs are not recovered.
  • X11 applications are not reopened, because niri does not reveal which X11 program owns a window.
  • Sessions inside terminals need Ghostty. Other terminals (kitty, WezTerm, foot, Alacritty) reopen like any app, from their own entry, without their sessions. In Ghostty, Claude Code, Pi and hook-announced agents resume by id; other programs get their last command run again, or a shell in the same directory. Sessions found in extra tabs of one Ghostty window reopen as separate windows.
  • Apps decide how many windows they reopen. A browser that restores fewer windows than were saved leaves the rest reported as not-detected; it is never launched a second time. Extra windows stay where the app put them.
  • Placement follows logical workspace order on the current output. Normal Niri empty-workspace creation/cleanup is supported; there is no arbitrary workspace-creation feature or source-monitor affinity restoration. Protected workspace names are not changed.
  • Saved widths and floating positions come back; tile heights do not. A window that cannot be placed in its saved column goes to the end of its workspace.
  • Stay idle while it arranges columns (usually under a minute). niri has no atomic focus-and-move, so input during the run can land in the wrong column.
  • Exact restart or migration of a still-running window is not supported and stays blocked.

Beyond reopening

The same CLI also plans blocked restart proposals and has a loss-bounded saved-conversation reconstruction path, which needs a separately owned adapter that does not ship here. It also has an experimental single-column reorder. None of these is needed to save and reopen a desktop. See planning, reconstruction and resolution.

Develop

uv sync --group dev
just check         # lint, formatting, tests, portable-source/privacy check
just build         # wheel + sdist
just ci            # check + build
just screenshots   # re-render docs/assets from the fabricated demo desktop (Chromium + ImageMagick)

Tests never contact a real compositor; releasing describes versions, tags and rollback. Architecture explains the module boundaries, DESIGN.md is the preview's visual contract and usage has every command's details. Screenshots come only from scripts/demo-desktop.py, and just check refuses PNG metadata that could carry private text.

Scaffolded from tpl-project-repo, then adapted for a standalone Python package. Copier answers retain relative template provenance only; template updates are a maintainer concern, not an installation prerequisite. Private template snapshot context is excluded from version control and distribution. Apache-2.0: see LICENSE.

The offline exec-observed-unassociated disposition v2 candidate uses explicit restore-disposition inspect|propose --family exec-observed-unassociated; omission preserves v1. It records partial accounting only, never retries or certifies restored native state. Review corrections require the actual launch-indeterminate witness, exact seven-field segment, tuple-based process identity and a live/expiry veto after the final capacity check. Earlier wrong-wire fixture results are not intended-family proof. The corrected implementation passed independent rereview, installed-wheel lifecycle checks on Python 3.13/3.14 and full isolated CI (1,671 tests). No live use or deployment is authorized by these offline results. See the family contract.

Metadata

Release files for niri-desktop-continuity 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for niri-desktop-continuity 0.2.1
File Size Uploaded Provenance Actions
niri_desktop_continuity-0.2.1.tar.gz 559.0 kB With provenance Details for niri_desktop_continuity-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for niri-desktop-continuity 0.2.1
File Interpreter ABI Platform Actions
niri_desktop_continuity-0.2.1-py3-none-any.whl Python 3 none any Details for niri_desktop_continuity-0.2.1-py3-none-any.whl

Total release size: 802.5 kB

Release files / niri_desktop_continuity-0.2.1.tar.gz

Download URL niri_desktop_continuity-0.2.1.tar.gz
Size 559.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ed68770d387e1c0e8dbbb261920ba34a129429283f486e4e5f25e5ad4709d4fb
BLAKE2b-256 checksum
How to use checksums
a053b52585254500c6894eddba867e25d2eed44a1c5e0fa510989a63dd683409
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / niri_desktop_continuity-0.2.1-py3-none-any.whl

Download URL niri_desktop_continuity-0.2.1-py3-none-any.whl
Size 243.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ce603543cbf1c1eeac571e5d5a66e70f7ca671090c77ae28595f7f74f4357c4
BLAKE2b-256 checksum
How to use checksums
6b876bceb87c93d73eae72259e3c6998b407bd4e81d5a78bfe1eb8f15e852421
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for niri-desktop-continuity 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for niri_desktop_continuity-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page