Skip to content

Instantly share code, notes, and snippets.

@HoKim98
Last active May 12, 2023 05:22
Show Gist options
  • Save HoKim98/ec67b1fdf4c6d4220687af74b22f5b23 to your computer and use it in GitHub Desktop.
Save HoKim98/ec67b1fdf4c6d4220687af74b22f5b23 to your computer and use it in GitHub Desktop.
Multi-screen (Multi-GPU) XFCE Settings
#!/bin/bash
# Copyright (c) 2023 Ho Kim (ho.kim@ulagbulag.io). All rights reserved.
# Prehibit errors
set -e -o pipefail
# Verbose
set -x
# Configure command-line arguments
SCREEN=$1
# Set local variables
DESKTOP_HOME="${HOME}/desktop/${SCREEN}"
# Install nvidia-ctk and generate NVIDIA GPU CDI
sudo dnf install -y nvidia-container-toolkit-base
mkdir -p /etc/cdi
nvidia-ctk cdi generate --device-name-strategy=type-index --format=json >/etc/cdi/nvidia.json 2>/dev/null
# Create a container-wise home directory
mkdir -p "${DESKTOP_HOME}"
# Build a desktop environment image
docker build --tag desktop .
# Spawn a desktop environment per screen
podman run -d --privileged \
--device nvidia.com/gpu=all \
--env "DISPLAY=:0.${SCREEN}" \
--name "desktop-${SCREEN}" \
--net host \
--restart unless-stopped \
--volume "${DESKTOP_HOME}:/root:rw" \
--volume /tmp/.ICE-unix:/tmp/.ICE-unix:rw \
--volume /tmp/.X11-unix:/tmp/.X11-unix:rw \
--volume /var/lib/dbus/machine-id:/var/lib/dbus/machine-id:ro \
--user $(id -u) \
--group-add $(id -g) \
desktop
# Finished!
exec echo "OK!"
# Copyright (c) 2023 Ho Kim (ho.kim@ulagbulag.io). All rights reserved.
# Configure environment variables
ARG ROCKYLINUX_VERSION="8"
# Be ready for serving
FROM "quay.io/rockylinux/rockylinux:${ROCKYLINUX_VERSION}" as base
# Install desktop environment dependencies
RUN dnf install -y \
epel-release \
&& dnf install -y \
dbus-x11 \
file-roller \
mesa-dri-drivers \
sqlite \
Thunar thunar-archive-plugin thunar-volman \
xfce4-appfinder xfce4-notifyd xfce4-panel xfce4-pulseaudio-plugin \
xfce4-session xfce4-settings xfce4-terminal \
xfconf xfdesktop xfwm4 \
# Cleanup
&& dnf clean all \
&& rm -rf /var/cache /var/log/dnf* /var/log/yum.*
# Execute xfce4-session after init
ENTRYPOINT [ "/usr/bin/env" ]
CMD [ "bash", "-c", "sleep 1; xfce4-session" ]
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" Below "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
Option "Xinerama" "0"
EndSection
Section "Files"
EndSection
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "NVIDIA TITAN V"
BusID "PCI:115:0:0"
EndSection
Section "Device"
Identifier "Device1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "NVIDIA TITAN V"
BusID "PCI:166:0:0"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Device0"
DefaultDepth 24
Option "Stereo" "0"
Option "SLI" "Off"
Option "MultiGPU" "Off"
Option "BaseMosaic" "off"
SubSection "Display"
Depth 24
EndSubSection
EndSection
Section "Screen"
Identifier "Screen1"
Device "Device1"
DefaultDepth 24
Option "Stereo" "0"
Option "SLI" "Off"
Option "MultiGPU" "Off"
Option "BaseMosaic" "off"
SubSection "Display"
Depth 24
EndSubSection
EndSection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment