Skip to content

Commit

Permalink
use smarter configuration defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCMcDonough committed Dec 1, 2023
1 parent 8f72e28 commit 1b56fd8
Showing 1 changed file with 52 additions and 21 deletions.
73 changes: 52 additions & 21 deletions scripts/setup_default_envs.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
#!/bin/sh

# Configure how hardware acceleration is set up.
# NODE — automatically regenerates device nodes using mknod
# GROUP — Adds user 1000 to the existing group mounted in.
export DRI_DEVICE_MODE="${DRI_DEVICE_MODE:-"NONE"}"
export UINPUT_DEVICE_MODE="${UINPUT_DEVICE_MODE:-"NONE"}"

# Enable or disable hardware acceleration
export DISABLE_HW_ACCEL="${DISABLE_HW_ACCEL:-"true"}"
# Tell FFMPEG to use Hardware Acceleration
export FFMPEG_HARDWARE="${FFMPEG_HARDWARE:-"1"}"

export DEV_DRI_PATH="${DEV_DRI_PATH:-"/dev/dri/"}"
export HOSTDEV_DRI_PATH="${HOSTDEV_DRI_PATH:-"/dev/host-dri/"}"

export DEV_UINPUT_PATH="${DEV_UINPUT_PATH:-"/dev/uinput"}"
export HOSTDEV_UINPUT_PATH="${HOSTDEV_UINPUT_PATH:-"/dev/host-uinput"}"

# Configure Displays and Audio for guest applications
export WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-"wayland-1"}"
export DISPLAY="${DISPLAY:-":0"}"
Expand All @@ -28,10 +11,58 @@ export PULSE_SERVER="${PULSE_SERVER:-"unix:/tmp/pulse/pulse-socket"}"
export WLR_NO_HARDWARE_CURSORS="${WLR_NO_HARDWARE_CURSORS:-"1"}"
# Configure Xwayland for X11 apps
export WLR_XWAYLAND="${WLR_XWAYLAND:-"/etc/sway/Xwayland"}"
# Vulkan didn't work for us
export WLR_RENDERER="${WLR_RENDERER:-"gles2"}"
# Necessary for docker
# Necessary for docker to run in headless mode
export WLR_BACKENDS="${WLR_BACKENDS:-"headless"}"

# Default the resolution
export RESOLUTION="${RESOLUTION:-"1280x720"}"

# Configure how hardware acceleration is set up.
# MKNOD — automatically regenerates device nodes using mknod
# GROUP — Adds user 1000 to the existing group mounted in.

# Configure hardware device paths
export DEV_DRI_PATH="${DEV_DRI_PATH:-"/dev/dri/"}"
export HOSTDEV_DRI_PATH="${HOSTDEV_DRI_PATH:-"/dev/host-dri/"}"

if [ -d /dev/host-dri ]; then
# We have hardware acceleration, we just need to make the nodes
export DRI_DEVICE_MODE="${DRI_DEVICE_MODE:-"MKNOD"}"
export DISABLE_HW_ACCEL="${DISABLE_HW_ACCEL:-"false"}"
export FFMPEG_HARDWARE="${FFMPEG_HARDWARE:-"1"}"
elif [ -d /dev/dri ]; then
# We have hardware acceleration, we just need to add permissions
export DRI_DEVICE_MODE="${DRI_DEVICE_MODE:-"GROUP"}"
export DISABLE_HW_ACCEL="${DISABLE_HW_ACCEL:-"false"}"
export FFMPEG_HARDWARE="${FFMPEG_HARDWARE:-"1"}"
else
# We do not have hardware acceleration. We should default disable it.
export DRI_DEVICE_MODE="${DRI_DEVICE_MODE:-"NONE"}"
export DISABLE_HW_ACCEL="${DISABLE_HW_ACCEL:-"true"}"
export FFMPEG_HARDWARE="${FFMPEG_HARDWARE:-"0"}"
fi

if [ $DISABLE_HW_ACCEL = "true" ]; then
export WLR_RENDERER="${WLR_RENDERER:-"pixman"}"
else
# Vulkan didn't work for us, so we default to GLES2
export WLR_RENDERER="${WLR_RENDERER:-"gles2"}"
fi

# Configure how gamepads are set up.
# MKNOD — automatically regenerates device nodes using mknod
# GROUP — Adds user 1000 to the existing group mounted in.

# Configure uinput paths
export DEV_UINPUT_PATH="${DEV_UINPUT_PATH:-"/dev/uinput"}"
export HOSTDEV_UINPUT_PATH="${HOSTDEV_UINPUT_PATH:-"/dev/host-uinput"}"

if [ -e /dev/host-uinput ]; then
# We can create gamepads, we just need to make the nodes
export UINPUT_DEVICE_MODE="${UINPUT_DEVICE_MODE:-"MKNOD"}"
elif [ -e /dev/uinput ]; then
# We can create gamepads, we just need to add permissions
export UINPUT_DEVICE_MODE="${UINPUT_DEVICE_MODE:-"GROUP"}"
else
# We do not have gamepad support. We should default disable it.
export UINPUT_DEVICE_MODE="${UINPUT_DEVICE_MODE:-"NONE"}"
fi

0 comments on commit 1b56fd8

Please sign in to comment.