Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/src/linux-x11-forwarding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Forward a local Linux host's X11 display into a development container.
| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| x11Display | Set DISPLAY for X11 clients launched from the container. | string | :0 |
| softwareGL | Set LIBGL_ALWAYS_SOFTWARE for GPU compatibility. | string | 1 |
| softwareGL | Force Mesa software rendering with LIBGL_ALWAYS_SOFTWARE=1. | boolean | false |

## Linux host requirements

Expand Down
10 changes: 3 additions & 7 deletions features/src/linux-x11-forwarding/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@
"description": "Set DISPLAY for X11 clients launched from the container."
},
"softwareGL": {
"type": "string",
"default": "1",
"proposals": [
"0",
"1"
],
"description": "Set LIBGL_ALWAYS_SOFTWARE for GPU compatibility."
"type": "boolean",
"default": false,
"description": "Force Mesa software rendering with LIBGL_ALWAYS_SOFTWARE=1."
}
},
"containerEnv": {
Expand Down
8 changes: 6 additions & 2 deletions features/src/linux-x11-forwarding/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

x11_display="${X11DISPLAY:-:0}"
software_gl="${SOFTWAREGL:-1}"
software_gl="${SOFTWAREGL:-false}"

cat >/etc/profile.d/devcontainer-x11-gui.sh <<EOF
host_runtime_dir="/tmp/devcontainer-host-runtime"
Expand All @@ -28,7 +28,11 @@ else
fi

export DISPLAY="${x11_display}"
export LIBGL_ALWAYS_SOFTWARE="${software_gl}"
if [ "${software_gl}" = "1" ] || [ "${software_gl}" = "true" ]; then
export LIBGL_ALWAYS_SOFTWARE=1
else
unset LIBGL_ALWAYS_SOFTWARE
fi
export QT_QPA_PLATFORM="xcb"
export XAUTHORITY="\${xauthority_target}"
EOF
Expand Down
2 changes: 1 addition & 1 deletion features/test/linux-x11-forwarding/host_forwarding_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source dev-container-features-test-lib

check "DISPLAY can be overridden from feature option" bash -lc '[ "${DISPLAY:-}" = ":99" ]'
check "XAUTHORITY stays on fixed path" bash -c '[ "${XAUTHORITY:-}" = "/tmp/devcontainer-xauthority" ]'
check "software rendering defaults through shell init" bash -lc '[ "${LIBGL_ALWAYS_SOFTWARE:-}" = "1" ]'
check "software rendering is not forced by default" bash -lc '[ -z "${LIBGL_ALWAYS_SOFTWARE:-}" ]'
check "Qt uses the X11 backend by default" bash -lc '[ "${QT_QPA_PLATFORM:-}" = "xcb" ]'
check "x11 socket directory is mounted" mountpoint -q /tmp/.X11-unix
check "runtime directory is mounted" mountpoint -q /tmp/devcontainer-host-runtime
Expand Down
10 changes: 9 additions & 1 deletion features/test/linux-x11-forwarding/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"linux-x11-forwarding": {
"softwareGL": "0"
"softwareGL": false
}
}
},
"software_gl_enabled": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"linux-x11-forwarding": {
"softwareGL": true
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion features/test/linux-x11-forwarding/software_gl_disabled.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

source dev-container-features-test-lib

check "software rendering can be disabled through shell init" bash -lc '[ "${LIBGL_ALWAYS_SOFTWARE:-}" = "0" ]'
check "software rendering remains unset when disabled" bash -lc '[ -z "${LIBGL_ALWAYS_SOFTWARE:-}" ]'
check "Qt uses the X11 backend by default" bash -lc '[ "${QT_QPA_PLATFORM:-}" = "xcb" ]'
check "x11 socket directory is mounted" mountpoint -q /tmp/.X11-unix
check "runtime directory is mounted" mountpoint -q /tmp/devcontainer-host-runtime
Expand Down
9 changes: 9 additions & 0 deletions features/test/linux-x11-forwarding/software_gl_enabled.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e
source dev-container-features-test-lib

check "software rendering can be enabled through shell init" bash -lc '[ "${LIBGL_ALWAYS_SOFTWARE:-}" = "1" ]'
check "Qt uses the X11 backend by default" bash -lc '[ "${QT_QPA_PLATFORM:-}" = "xcb" ]'

reportResults
2 changes: 1 addition & 1 deletion features/test/linux-x11-forwarding/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source dev-container-features-test-lib

check "DISPLAY defaults to :0" bash -lc '[ "${DISPLAY:-}" = ":0" ]'
check "XAUTHORITY is set to fixed path" bash -c '[ "${XAUTHORITY:-}" = "/tmp/devcontainer-xauthority" ]'
check "software rendering defaults through shell init" bash -lc '[ "${LIBGL_ALWAYS_SOFTWARE:-}" = "1" ]'
check "software rendering is not forced by default" bash -lc '[ -z "${LIBGL_ALWAYS_SOFTWARE:-}" ]'
check "Qt uses the X11 backend by default" bash -lc '[ "${QT_QPA_PLATFORM:-}" = "xcb" ]'
check "XDG runtime directory is private and writable" bash -lc '[ "${XDG_RUNTIME_DIR:-}" = "/tmp/devcontainer-runtime-$(id -u)" ] && [ -d "${XDG_RUNTIME_DIR}" ] && [ -w "${XDG_RUNTIME_DIR}" ] && [ "$(stat -c %a "${XDG_RUNTIME_DIR}")" = "700" ]'
check "x11 socket directory exists" bash -c '[ -d /tmp/.X11-unix ]'
Expand Down