Some time ago, 'WLR_RENDERER=pixman' stopped working properly on virtio. Appears that it only affects the atomic KMS and falling back to the legacy DRM interface was enough to work around. While legacy is a less tested codepath, I don't see any other ways to address that :'(
65 lines
2.2 KiB
Bash
Executable file
65 lines
2.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
## Internal variables
|
|
SWAY_EXTRA_ARGS=""
|
|
|
|
## General exports
|
|
export XDG_CURRENT_DESKTOP=sway
|
|
export XDG_SESSION_DESKTOP=sway
|
|
export XDG_SESSION_TYPE=wayland
|
|
|
|
## Hardware compatibility
|
|
# We can't be sure that the virtual GPU is compatible with Sway.
|
|
# We should be attempting to detect an EGL driver instead, but that appears
|
|
# to be a bit more complicated.
|
|
case $(systemd-detect-virt --vm) in
|
|
"none"|"")
|
|
;;
|
|
"kvm")
|
|
# There's two drivers we can get here, depending on the 3D acceleration
|
|
# flag state: either virtio_gpu/virgl or kms_swrast/llvmpipe.
|
|
#
|
|
# The former one causes graphical glitches in OpenGL apps when using
|
|
# 'pixman' renderer. The latter will crash 'gles2' renderer outright.
|
|
# Neither of those support 'vulkan'.
|
|
#
|
|
# The choice is obvious, at least until we learn to detect the driver
|
|
# instead of abusing the virtualization technology identifier.
|
|
#
|
|
# See also: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2871
|
|
export WLR_RENDERER=pixman
|
|
# 'pixman' on virtio_gpu with recent kernels is glitchy. Appears that
|
|
# it only affects atomic KMS, and legacy interface works.
|
|
export WLR_DRM_NO_ATOMIC=1
|
|
# WLR_NO_HARDWARE_CURSORS=1 is not needed with legacy DRM interface
|
|
;;
|
|
*)
|
|
# https://github.com/swaywm/sway/issues/6581
|
|
export WLR_NO_HARDWARE_CURSORS=1
|
|
;;
|
|
esac
|
|
|
|
## Load system environment customizations
|
|
if [ -f /etc/sway/environment ]; then
|
|
set -o allexport
|
|
# shellcheck source=/dev/null
|
|
. /etc/sway/environment
|
|
set +o allexport
|
|
fi
|
|
|
|
## Load user environment customizations
|
|
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/sway/environment" ]; then
|
|
set -o allexport
|
|
# shellcheck source=/dev/null
|
|
. "${XDG_CONFIG_HOME:-$HOME/.config}/sway/environment"
|
|
set +o allexport
|
|
fi
|
|
|
|
## Unexport internal variables
|
|
# export -n is not POSIX :(
|
|
_SWAY_EXTRA_ARGS="$SWAY_EXTRA_ARGS"
|
|
unset SWAY_EXTRA_ARGS
|
|
|
|
# Start sway with extra arguments and send output to the journal
|
|
# shellcheck disable=SC2086 # quoted expansion of EXTRA_ARGS can produce empty field
|
|
exec systemd-cat -- /usr/bin/sway $_SWAY_EXTRA_ARGS "$@"
|