Files

4.6 KiB

nextcloud-niri

A lightweight, headless Common Lisp (SBCL) Nextcloud bidirectional sync client and Waybar text widget for niri — zero Qt, zero GUI bloat.

Warning: AI-generated ("vibe coded") software

This project was created entirely by an AI agent (Gemini 4 Neon). It is vibe coded software: the sync engine, Linux inotify watcher, Unix socket IPC, and Waybar renderer were verified mechanically against an in-process mock WebDAV server (./build.sh test runs all 69 assertions), but no human has read it end to end. Use it with that in mind — especially since it syncs and deletes files — keep backups, and treat anything surprising as a bug worth reporting.

Features

  • Real 3-way bidirectional WebDAV sync:

    • Uploads local edits (with X-OC-Mtime), downloads remote edits (preserving timestamps atomically), and propagates deletions in both directions.
    • Nextcloud oc:etag pruning: periodic remote polls issue a single PROPFIND Depth: 0 when nothing changed on the server, and prune unchanged subdirectories during scans.
    • Conflict-safe: concurrent edits to the same file never lose data — local changes are preserved as <name> (conflicted copy YYYY-MM-DD HHMMSS)<ext> and synced alongside the remote version.
    • SHA-256 content verification: touching a file's mtime without modifying bytes won't trigger redundant uploads.
    • Nextcloud Chunked Upload v2: files larger than :chunk-size-mb (default 10 MB) are uploaded in chunks to avoid reverse-proxy size limits.
    • Missing-folder safety guard: if a synced local directory disappears (e.g., unmounted drive), sync stops with an error instead of deleting remote files.
  • Instant local watching: pure SBCL sb-alien Linux inotify recursive watcher (automatically tracks new subdirectories, debounces rapid editor saves).
  • Nextcloud Login Flow v2: authenticate in your browser (supports 2FA/SSO) and receive a dedicated Nextcloud app password stored with 0600 permissions — or use :password-cmd (e.g., pass, secret-tool).
  • Waybar native text widget:

    • Instant updates via Waybar SIGRTMIN+7 (no polling lag).
    • Clean lowercase text states:

      • nc — synced
      • nc * / nc *3 — unsynced (local changes pending)
      • nc ... / nc 2/5 — actively syncing
      • nc ! — problem syncing (hover tooltip shows exact error)
      • nc paused — paused
      • nc off — daemon stopped
    • Left-click to sync immediately, right-click to pause/resume.

Build & Install

Requires SBCL and Quicklisp.

./build.sh test     # run full end-to-end test suite (69 assertions)
./build.sh build    # compile standalone native binary ./nextcloud-niri
./build.sh install  # install to ~/.local/bin/nextcloud-niri + systemd user unit

A Makefile with identical targets is also included.

Quick Start

  1. Authenticate with your Nextcloud server (opens browser via Login Flow v2; pass --manual to enter username & app password directly):

    nextcloud-niri login https://cloud.example.com
  2. Add synced folder pairs:

    nextcloud-niri add ~/Documents/Notes Documents/Notes

    Or edit ~/.config/nextcloud-niri/config.sexp directly (see config.example.sexp).

  3. Start the background daemon (starts automatically with niri.service):

    systemctl --user daemon-reload
    systemctl --user enable --now nextcloud-niri.service
  4. Add the Waybar widget:

CLI Reference

nextcloud-niri waybar                          # Print Waybar JSON status
nextcloud-niri daemon                          # Run background sync daemon
nextcloud-niri sync [--full]                   # Trigger sync (or one-shot if daemon stopped)
nextcloud-niri status                          # Show status in terminal
nextcloud-niri pause | resume | toggle         # Pause/resume background daemon
nextcloud-niri reload                          # Reload config.sexp in running daemon
nextcloud-niri login <url> [--manual]          # Authenticate via Login Flow v2
nextcloud-niri add <local> <remote> [--name N] # Add synced folder pair
nextcloud-niri remove <name>                   # Remove synced folder pair
nextcloud-niri list                            # List configured folder pairs