#+TITLE: nextcloud-niri #+AUTHOR: venomade #+OPTIONS: toc:nil A lightweight, headless Common Lisp (SBCL) Nextcloud bidirectional sync client and Waybar text widget for *niri* — zero Qt, zero GUI bloat. * 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 = (conflicted copy YYYY-MM-DD HHMMSS)= 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. #+begin_src bash ./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 #+end_src 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): #+begin_src bash nextcloud-niri login https://cloud.example.com #+end_src 2. *Add synced folder pairs*: #+begin_src bash nextcloud-niri add ~/Documents/Notes Documents/Notes #+end_src Or edit =~/.config/nextcloud-niri/config.sexp= directly (see [[file:config.example.sexp][config.example.sexp]]). 3. *Start the background daemon* (starts automatically with =niri.service=): #+begin_src bash systemctl --user daemon-reload systemctl --user enable --now nextcloud-niri.service #+end_src 4. *Add the Waybar widget*: - Copy [[file:waybar/config.snippet.jsonc][waybar/config.snippet.jsonc]] into =~/.config/waybar/config= and add ="custom/nextcloud"= to ="modules-right"=. - Append [[file:waybar/style.snippet.css][waybar/style.snippet.css]] to =~/.config/waybar/style.css=. - Reload Waybar (=pkill -SIGUSR2 waybar=). * CLI Reference #+begin_example 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 [--manual] # Authenticate via Login Flow v2 nextcloud-niri add [--name N] # Add synced folder pair nextcloud-niri remove # Remove synced folder pair nextcloud-niri list # List configured folder pairs #+end_example