|
| 1 | +# Handover: Restore, IPC, and Consumer Compatibility |
| 2 | + |
| 3 | +Date: 2026-07-08 |
| 4 | +Branch: `fix/restore-ipc-state-compat` |
| 5 | +PR: https://github.com/Nomadcxx/gSlapper/pull/17 |
| 6 | +Implementation commit: `85d232d` |
| 7 | + |
| 8 | +## Scope |
| 9 | + |
| 10 | +This session focused on pre-release correctness around restore/state behavior and compatibility with projects that invoke gSlapper as a backend. The work intentionally stayed narrow: command-line restore handling, IPC command behavior, state file durability, documentation alignment, and consumer smoke checks. |
| 11 | + |
| 12 | +## Changes Made |
| 13 | + |
| 14 | +### Restore CLI |
| 15 | + |
| 16 | +- `gslapper --restore` now accepts the documented restore shape without requiring a normal wallpaper positional argument. |
| 17 | +- `gslapper --restore [output]` is now shown in `--help`. |
| 18 | +- Wildcard/all-output restore selectors (`*`, `all`, `All`, `ALL`) restore from the default `state.txt` instead of an output-specific `state-_.txt`. |
| 19 | +- `--state-file PATH` is now honored during restore. |
| 20 | +- If restore fails and no fallback wallpaper was supplied, gSlapper exits with a clear error instead of falling through ambiguously. |
| 21 | +- Restore with a fallback wallpaper remains supported: `gslapper --restore <output> <fallback>`. |
| 22 | + |
| 23 | +### State Saving |
| 24 | + |
| 25 | +- State saving for wildcard/all-output runs now records the logical selector while still using the default state file path. |
| 26 | +- The atomic writer in `src/state.c` now uses a unique temporary file (`mkstemp`) instead of a fixed `<state>.tmp` path. |
| 27 | +- This fixes a real local failure where an abandoned `state.txt.tmp` permanently blocked all future saves with `Failed to create temp state file`. |
| 28 | +- Temp files are still created in the same directory and renamed into place, preserving atomic replacement semantics. |
| 29 | +- Temp state file permissions are explicitly set to `0600`. |
| 30 | + |
| 31 | +### IPC |
| 32 | + |
| 33 | +- Added IPC `quit` as an alias for `stop`. |
| 34 | +- Added the documented IPC `save-state` command. |
| 35 | +- Updated IPC help text to list `stop, quit` and `save-state`. |
| 36 | +- Fixed IPC response fd ownership: |
| 37 | + - The client thread now duplicates the accepted client fd for each queued command. |
| 38 | + - The main loop owns that duplicate until it sends the response. |
| 39 | + - The queued command cleanup closes the response fd. |
| 40 | +- This fixes the observed behavior where `socat` received an empty response and gSlapper logged `Failed to send IPC response: Bad file descriptor`. |
| 41 | +- Multiple newline-delimited commands on one socket connection were tested and still work. |
| 42 | + |
| 43 | +### Documentation |
| 44 | + |
| 45 | +- Updated `docs/user-guide/ipc-control.md`: |
| 46 | + - Documents `stop` / `quit`. |
| 47 | + - Documents IPC `save-state`. |
| 48 | +- Updated `docs/development/api-reference.md`: |
| 49 | + - Adds `quit` beside `stop`. |
| 50 | + - Adds `save-state`. |
| 51 | + |
| 52 | +## Consumer Compatibility Assessment |
| 53 | + |
| 54 | +### Waytrogen |
| 55 | + |
| 56 | +Repository checked: https://github.com/nikolaizombie1/waytrogen |
| 57 | + |
| 58 | +Current Waytrogen gSlapper integration invokes gSlapper approximately as: |
| 59 | + |
| 60 | +```bash |
| 61 | +gslapper -I /tmp/gslapper.sock [-p|-s] -o "<scale loop no-audio additional>" -f <monitor|*> <image> |
| 62 | +``` |
| 63 | + |
| 64 | +It also tries to stop an existing gSlapper instance with: |
| 65 | + |
| 66 | +```bash |
| 67 | +echo quit | socat - UNIX-CONNECT:/tmp/gslapper.sock |
| 68 | +``` |
| 69 | + |
| 70 | +and falls back to `pkill -9 gslapper`. |
| 71 | + |
| 72 | +Assessment: |
| 73 | + |
| 74 | +- The launch shape remains compatible. |
| 75 | +- The new IPC `quit` alias directly supports Waytrogen's graceful shutdown path. |
| 76 | +- Before this fix, Waytrogen would rely on its forced-kill fallback because gSlapper did not handle `quit`. |
| 77 | +- After this fix, `quit` returns `OK` and exits cleanly in local live IPC testing. |
| 78 | + |
| 79 | +### Waypaper |
| 80 | + |
| 81 | +Repository checked: https://github.com/anufrievroman/waypaper |
| 82 | + |
| 83 | +Current Waypaper gSlapper integration invokes gSlapper approximately as: |
| 84 | + |
| 85 | +```bash |
| 86 | +gslapper --fork -o "loop <fill-mode> [no-audio] [user-options]" <monitor|*> <path> |
| 87 | +``` |
| 88 | + |
| 89 | +It does not use gSlapper IPC for normal operation. It stops gSlapper with process killing (`killall gslapper` for all outputs or monitor-pattern matching for a specific output). |
| 90 | + |
| 91 | +Assessment: |
| 92 | + |
| 93 | +- The launch shape remains compatible. |
| 94 | +- Local smoke tests started Waypaper-shaped commands with these option variants: `panscan=1.0`, `original`, `stretch`, and `fill`. |
| 95 | +- No parser, startup, or immediate runtime errors were observed for those command shapes. |
| 96 | +- There is one semantic mismatch worth noting: Waypaper maps its UI `fill` option to gSlapper `panscan=1.0`. In current gSlapper semantics, `panscan=1.0` behaves like contain/fit, while gSlapper `fill` is cover/crop. This is not a gSlapper release blocker, but it is a good future upstream fix for Waypaper's backend mapping. |
| 97 | + |
| 98 | +## Local Verification |
| 99 | + |
| 100 | +Ran on this laptop against the rebuilt local binary: |
| 101 | + |
| 102 | +```bash |
| 103 | +ninja -C build |
| 104 | +tests/test_basic.sh |
| 105 | +``` |
| 106 | + |
| 107 | +Result: |
| 108 | + |
| 109 | +- Build passed. |
| 110 | +- Basic integration tests passed: 16 passed, 0 failed. |
| 111 | +- Existing warning remains in `output_description`: discards `const` qualifier. This was left out of scope. |
| 112 | + |
| 113 | +Live checks performed: |
| 114 | + |
| 115 | +- `gslapper --restore --state-file /tmp/gslapper-definitely-missing` |
| 116 | + - Exits `1` with explicit missing-state/fallback error. |
| 117 | +- `gslapper --restore '*'` |
| 118 | + - No longer fails with the old positional-argument error. |
| 119 | +- IPC over Unix socket: |
| 120 | + - `query` returns status. |
| 121 | + - `save-state` returns `OK: state saved`. |
| 122 | + - `help` lists the expected commands. |
| 123 | + - `quit` returns `OK` and exits. |
| 124 | + - Multi-command socket input returned responses correctly. |
| 125 | +- Waypaper-shaped launch commands: |
| 126 | + - `loop panscan=1.0 no-audio` |
| 127 | + - `loop original no-audio` |
| 128 | + - `loop stretch no-audio` |
| 129 | + - `loop fill no-audio` |
| 130 | + |
| 131 | +The rebuilt binary was installed to the active user path: |
| 132 | + |
| 133 | +```bash |
| 134 | +/home/nomadx/.local/bin/gslapper |
| 135 | +``` |
| 136 | + |
| 137 | +The installed user-local binary hash matched `build/gslapper` after installation. |
| 138 | + |
| 139 | +## Process Hygiene |
| 140 | + |
| 141 | +Extra smoke-test gSlapper processes were cleaned up. The only gSlapper process intentionally left running was the existing sysc-greet wallpaper instance: |
| 142 | + |
| 143 | +```bash |
| 144 | +gslapper -f -I /tmp/sysc-greet-wallpaper.sock * /usr/share/sysc-greet/wallpapers/sysc-greet-dark.png |
| 145 | +``` |
| 146 | + |
| 147 | +## Follow-Ups |
| 148 | + |
| 149 | +- Review PR #17 on a second environment before merging. |
| 150 | +- Consider an upstream Waypaper issue or PR to map Waypaper UI `fill` to gSlapper `fill` instead of `panscan=1.0`. |
| 151 | +- Consider a small follow-up cleanup for old backup files under `src/`, because they pollute search results with stale `clappie` and old IPC/state behavior. |
| 152 | +- Consider separately fixing the existing `output_description` `const` warning. |
0 commit comments