From 0f6b2530ef2c0e792ed2e9dee11e433add19c6d8 Mon Sep 17 00:00:00 2001
From: Seungmin Kim <8457324+ehfd@users.noreply.github.com>
Date: Thu, 1 Aug 2024 20:04:44 +0900
Subject: [PATCH] Edit X11
---
Dockerfile | 1 +
README.md | 15 ++++++++++++++-
entrypoint.sh | 15 ++-------------
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 2d0be85..9830bbb 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -461,6 +461,7 @@ ENV KDE_SESSION_VERSION=5
ENV KDE_APPLICATIONS_AS_SCOPE=1
ENV KWIN_COMPOSE=N
ENV KWIN_EFFECTS_FORCE_ANIMATIONS=0
+ENV KWIN_EXPLICIT_SYNC=0
ENV KWIN_X11_NO_SYNC_TO_VBLANK=1
# Use sudoedit to change protected files instead of using sudo on kwrite
ENV SUDO_EDITOR=kwrite
diff --git a/README.md b/README.md
index fcd556e..e30636b 100644
--- a/README.md
+++ b/README.md
@@ -354,6 +354,19 @@ Do not use `systemd`, `polkit`, FUSE mounts, or sandboxed application distributi
+### I want to use this container with laptops or other integrated/hybrid GPU systems.
+
+
+ Open Answer
+
+If you need a container that works out of the box, you should use [docker-nvidia-egl-desktop](https://github.com/selkies-project/docker-nvidia-egl-desktop).
+
+This container may work after some substantial configuration with the internal X.Org X11 server of the container, but is not guaranteed or officially supported.
+
+Some references include [https://wiki.archlinux.org/title/NVIDIA_Optimus](https://wiki.archlinux.org/title/NVIDIA_Optimus), [https://wiki.archlinux.org/title/Bumblebee](https://wiki.archlinux.org/title/Bumblebee), and [https://wiki.debian.org/NVIDIA%20Optimus](https://wiki.debian.org/NVIDIA%20Optimus).
+
+
+
### I want to share one GPU with multiple containers to run GUI workloads.
@@ -383,7 +396,7 @@ Then, edit the `/etc/X11/xorg.conf` file of your host outside the container and
```
Section "ServerFlags"
- Option "AutoAddGPU" "false"
+ Option "AutoAddGPU" "False"
EndSection
```
diff --git a/entrypoint.sh b/entrypoint.sh
index 857e75c..348347a 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -80,14 +80,6 @@ if ! command -v nvidia-xconfig >/dev/null 2>&1; then
fi
fi
-# Allow starting Xorg from a pseudoterminal instead of strictly on a tty console
-if [ ! -f /etc/X11/Xwrapper.config ]; then
- echo -e "allowed_users=anybody\nneeds_root_rights=yes" | tee /etc/X11/Xwrapper.config > /dev/null
-fi
-if grep -Fxq "allowed_users=console" /etc/X11/Xwrapper.config; then
- sed -i "s/allowed_users=console/allowed_users=anybody/;$ a needs_root_rights=yes" /etc/X11/Xwrapper.config
-fi
-
# Remove existing Xorg configuration
if [ -f "/etc/X11/xorg.conf" ]; then
rm -f "/etc/X11/xorg.conf"
@@ -136,13 +128,10 @@ sed -i '/Section\s\+"Monitor"/a\ '"$MODELINE" /etc/X11/xorg.conf
sed -i '/"DPMS"/d' /etc/X11/xorg.conf
sed -i '/Section\s\+"Monitor"/a\ Option "DPMS" "False"' /etc/X11/xorg.conf
# Prevent interference between GPUs, add this to the host or other containers running Xorg as well
-echo -e "Section \"ServerFlags\"\n Option \"DontVTSwitch\" \"True\"\n Option \"DontZap\" \"True\"\n Option \"AllowMouseOpenFail\" \"True\"\n Option \"AutoAddGPU\" \"False\"\n Option \"AutoBindGPU\" \"False\"\nEndSection" | tee -a /etc/X11/xorg.conf > /dev/null
-
-# Real sudo (sudo-root) is required in Ubuntu 20.04 but not newer Ubuntu, this symbolic link enables running Xorg inside a container with `-sharevts`
-ln -snf /dev/ptmx /dev/tty7 || sudo-root ln -snf /dev/ptmx /dev/tty7 || echo 'Failed to create /dev/tty7 device'
+echo -e "Section \"ServerFlags\"\n Option \"DontVTSwitch\" \"True\"\n Option \"DontZap\" \"True\"\n Option \"AllowMouseOpenFail\" \"True\"\n Option \"AutoAddGPU\" \"False\"\nEndSection" | tee -a /etc/X11/xorg.conf > /dev/null
# Run Xorg server with required extensions
-/usr/bin/Xorg "${DISPLAY}" vt7 -noreset -novtswitch -sharevts -nolisten "tcp" -ac -dpi "${DISPLAY_DPI}" +extension "COMPOSITE" +extension "DAMAGE" +extension "GLX" +extension "RANDR" +extension "RENDER" +extension "MIT-SHM" +extension "XFIXES" +extension "XTEST" &
+/usr/lib/xorg/Xorg "${DISPLAY}" vt7 -noreset -novtswitch -sharevts -nolisten "tcp" -ac -dpi "${DISPLAY_DPI}" +extension "COMPOSITE" +extension "DAMAGE" +extension "GLX" +extension "RANDR" +extension "RENDER" +extension "MIT-SHM" +extension "XFIXES" +extension "XTEST" &
# Wait for X server to start
echo 'Waiting for X Socket' && until [ -S "/tmp/.X11-unix/X${DISPLAY#*:}" ]; do sleep 0.5; done && echo 'X Server is ready'