Skip to content

Commit 335de9d

Browse files
netplebclaude
andcommitted
fix: handle absolute WAYLAND_DISPLAY in -d desktop binding
WAYLAND_DISPLAY may be an absolute path, in which case XDG_RUNTIME_DIR must not be prepended. The old code always concatenated them, producing a malformed path like /run/user/1001//run/user/1000/wayland-0 and a bwrap "Can't find source path" error. Detect the absolute form, use it as-is, and guard the bind with an existence check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3991397 commit 335de9d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

wrap.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,18 @@ while getopts "r:w:e:abcdfhmnpuv" opt; do
211211
# grant desktop access (Wayland or X11) and rendering hardware access
212212
d)
213213
if [ -n "${WAYLAND_DISPLAY:-}" ] && [ -n "${XDG_RUNTIME_DIR:-}" ]; then
214-
# Using Wayland: bind the Wayland display socket
215-
bwrap_opts+=(--bind "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY")
214+
# Using Wayland: bind the Wayland display socket.
215+
# WAYLAND_DISPLAY may be either a bare socket name (resolved relative to
216+
# XDG_RUNTIME_DIR, the common case) or an absolute path (in which case
217+
# XDG_RUNTIME_DIR must NOT be prepended). Handle both.
218+
if [[ "$WAYLAND_DISPLAY" = /* ]]; then
219+
wayland_socket="$WAYLAND_DISPLAY"
220+
else
221+
wayland_socket="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY"
222+
fi
223+
if [ -e "$wayland_socket" ]; then
224+
bwrap_opts+=(--bind "$wayland_socket" "$wayland_socket")
225+
fi
216226
fi
217227

218228
if [ -n "${DISPLAY:-}" ]; then

0 commit comments

Comments
 (0)