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:etagpruning: periodic remote polls issue a singlePROPFIND Depth: 0when 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.
- Uploads local edits (with
- Instant local watching: pure SBCL
sb-alienLinuxinotifyrecursive 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
0600permissions — 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— syncednc */nc *3— unsynced (local changes pending)nc .../nc 2/5— actively syncingnc !— problem syncing (hover tooltip shows exact error)nc paused— pausednc off— daemon stopped
- Left-click to sync immediately, right-click to pause/resume.
- Instant updates via Waybar
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
-
Authenticate with your Nextcloud server (opens browser via Login Flow v2; pass
--manualto enter username & app password directly):nextcloud-niri login https://cloud.example.com -
Add synced folder pairs:
nextcloud-niri add ~/Documents/Notes Documents/NotesOr edit
~/.config/nextcloud-niri/config.sexpdirectly (see config.example.sexp). -
Start the background daemon (starts automatically with
niri.service):systemctl --user daemon-reload systemctl --user enable --now nextcloud-niri.service -
Add the Waybar widget:
- Copy waybar/config.snippet.jsonc into
~/.config/waybar/configand add"custom/nextcloud"to"modules-right". - Append waybar/style.snippet.css to
~/.config/waybar/style.css. - Reload Waybar (
pkill -SIGUSR2 waybar).
- Copy waybar/config.snippet.jsonc into
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