1. Create the project
Initialize a Zig project and add Otter dependencies inbuild.zig.zon:
2. Wire imports in build.zig
3. Choose your app pattern
Layer-shell overlay (launcher, logout, settings style)
- Connect to Wayland via
otter-wayland - Create a
zwlr_layer_shell_v1surface - Describe UI with Surface Description (
otter-uiUiFrame) - One-shot: use
ArenaAllocator, exit after user action - Examples:
otter-launcher,otter-logout
Persistent daemon (bar, notifications, wallpaper style)
- Long-running event loop polling Wayland + D-Bus/inotify FDs
- Use
GeneralPurposeAllocator - Hot-reload config via
otter-conf.Watcher - Examples:
otter-bar,otter-notifications
CLI tool (calc, weather, emoji style)
- Minimal deps:
otter-tools-core+otter-conf - No Wayland window unless you add a
--layerpopup mode - Examples:
otter-calc,otter-weather
4. Build the UI with Surface Description
New app UI should use the boundedUiState frame API:
state.hitTest(point) for pointer input. No parallel hit arrays needed.
5. Add configuration
Define a config struct and parse it withotter-conf:
~/.config/otter-shell/my-app.conf. On first run, normalize the file (add missing defaults, strip unknown keys).
For typed configs shared with otter-settings, add structs to otter-config-types and register a tab in otter-settings/src/tabs.zig.
6. Apply theming
Load the shared theme:?Color = null and resolve via config.field orelse theme.token. Precedence: widget config, then theme.conf, then compiled defaults.
7. Install a .desktop file
For launcher integration, install a freedesktop.desktop entry:
data/applications/ and install icons under data/icons/hicolor/.
Reference implementations
| Pattern | Study these sources |
|---|---|
| Status bar daemon | otter-bar/src/main.zig, otter-bar/src/config.zig |
| One-shot overlay | otter-launcher/src/main.zig, otter-launcher/src/draw.zig |
| Region capture / selection | otter-screenshot/src/main.zig, otter-wayland/src/selection_overlay.zig |
| Settings GUI | otter-settings/src/app.zig, otter-settings/src/draw_form.zig |
| CLI helper | otter-calc/src/main.zig, otter-tools-core/src/calc.zig |
| Config-only daemon | otter-idle/src/main.zig |

