Skip to content

ccbox: fall back to wayland-0 socket and warn when clipboard is unwirable - #92

Merged
guimou merged 1 commit into
mainfrom
clipboard-wayland-fallback
Nov 17, 2026
Merged

guimou merged 1 commit into
mainfrom
clipboard-wayland-fallback

Conversation

@guimou

@guimou guimou commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • add_clipboard_mounts() uses $WAYLAND_DISPLAY only when its socket actually exists, and falls back to $XDG_RUNTIME_DIR/wayland-0 when the variable is unset or stale but the socket is live — the same default as libwayland's wl_display_connect(NULL). This covers shells born outside the graphical session (SSH, daemons, stripped envs, terminal multiplexer servers), where the socket is present but the variable is not.
  • A clipboard-blind launch is no longer silent: log_warn "No display server found: clipboard image pasting will not work", and the status line reports enabled (Wayland) / enabled (X11) / unavailable (no display server) instead of a blanket enabled.
  • docs/usage.md clipboard section updated to match.

Context

Diagnosed from a real failure: on a Fedora workstation with a live wayland-0 socket and XDG_RUNTIME_DIR set, interactive shells had empty WAYLAND_DISPLAY/DISPLAY (vars present in the systemd user environment but not inherited by the shell). The old detection required the variable, so ccbox launched containers with zero clipboard wiring and no message — image paste (Ctrl+V) silently did nothing, identical inside and outside Herdr. The fallback makes such a machine work out of the box; the warning makes any remaining case visible in one line.

Verification

  • tests/render-test.sh: 48/48 ok, goldens unchanged (the fallback only fires when a socket exists, which the fixture env never has).
  • shellcheck lib/box-common.sh + bash -n clean.
  • End-to-end with a stub runtime, five paths:
    • runtime dir + live socket, display vars empty → mounts the socket, sets WAYLAND_DISPLAY=wayland-0, status enabled (Wayland)
    • explicit WAYLAND_DISPLAY with existing socket → honored
    • stale WAYLAND_DISPLAY=wayland-99, wayland-0 live → falls back, status enabled (Wayland)
    • headless (no runtime dir, no X11) → [WARN] No display server found, status unavailable (no display server)
    • --no-clipboard → status disabled, no mounts

…able

- add_clipboard_mounts() now uses \$WAYLAND_DISPLAY only when its socket exists,
  and falls back to \$XDG_RUNTIME_DIR/wayland-0 when the variable is unset or
  stale but the socket is live (shells born outside the graphical session:
  SSH, daemons, stripped envs) — mirrors libwayland's connect(NULL) default.
- A clipboard-blind launch is no longer silent: log_warn 'No display server
  found' and the status line now reports enabled (Wayland) / (X11) /
  unavailable (no display server) instead of a blanket 'enabled'.
- docs/usage.md clipboard section updated to match.
@guimou
guimou merged commit d2d0b24 into main Nov 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant