Add opt-in GUI and audio support

This commit is contained in:
2026-10-27 11:37:27 +01:00
parent ea23cf1a50
commit a2cda697dd
4 changed files with 58 additions and 4 deletions

View File

@@ -10,7 +10,8 @@
# claudio update rebuild from scratch (latest Debian + Claude Code)
#
# The current directory is mounted at its own path. If it contains a .claudio
# file, that file is sourced (bash) for extra mounts and options.
# file, that file is sourced (bash) for extra mounts and options, and can set
# GUI=1 / AUDIO=1 to share the host's Wayland / PulseAudio sockets.
# The container's home (/home/claude: login, settings, history) lives in the
# global podman volume "claudio-home".
set -euo pipefail
@@ -34,7 +35,7 @@ fi
podman image exists "$IMAGE" || build
# Project settings (see the .claudio template).
MOUNTS=() PODMAN_ARGS=() CLAUDE_ARGS=()
MOUNTS=() PODMAN_ARGS=() CLAUDE_ARGS=() GUI=0 AUDIO=0
if [[ -f .claudio ]]; then source ./.claudio; fi
args=(-v "$PWD:$PWD" -w "$PWD" -v "$VOLUME:/home/claude")
@@ -43,6 +44,26 @@ for m in "${MOUNTS[@]}"; do
args+=(-v "$m")
done
# GUI/AUDIO: share a socket from the host's runtime dir into the container's.
host_run="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
share() {
[[ -S "$host_run/$1" ]] || { echo "claudio: no socket at $host_run/$1" >&2; exit 1; }
args+=(-v "$host_run/$1:/run/user/1000/$1")
}
if [[ "$GUI" == 1 ]]; then
wl="${WAYLAND_DISPLAY:-wayland-0}"
share "$wl"
args+=(-e WAYLAND_DISPLAY="$wl" -e GDK_BACKEND=wayland -e QT_QPA_PLATFORM=wayland
-e SDL_VIDEODRIVER=wayland -e ELECTRON_OZONE_PLATFORM_HINT=wayland)
if [[ -e /dev/dri ]]; then args+=(--device /dev/dri); fi
fi
if [[ "$AUDIO" == 1 ]]; then
share pulse/native
args+=(-e PULSE_SERVER=unix:/run/user/1000/pulse/native)
fi
if [[ "${1:-}" == shell ]]; then
shift
args+=(--entrypoint bash)