-
Notifications
You must be signed in to change notification settings - Fork 3
/
sommelier-wrapper
executable file
·41 lines (34 loc) · 1.43 KB
/
sommelier-wrapper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -eu
BINDIR="$(dirname "$(command -v "${0}")")"
ARCH="$(uname -m)"
[[ "${ARCH}" == 'x86_64' ]] && LIB_SUFFIX='64' || LIB_SUFFIX=''
export XDG_RUNTIME_DIR=/var/run/chrome
export LD_ARGV0_REL=../bin/sommelier
# get a list of all available DRM render nodes
DRM_DEVICES_LIST=( /sys/class/drm/renderD* )
# if two or more render nodes available, choose one based on the corresponding render device path:
# devices/platform/vegm/...: virtual GEM device provided by Chrome OS, hardware acceleration may not available on this node. (should be avoided)
# devices/pci*/...: linked to the actual graphics card device path, provided by graphics card driver. (preferred)
#
if [[ "${#DRM_DEVICES_LIST[@]}" > 1 ]]; then
for dev in ${DRM_DEVICES_LIST[@]}; do
if [[ "$(coreutils --coreutils-prog=readlink -f "${dev}")" =~ devices/pci ]]; then
SOMMELIER_DRM_DEVICE="/dev/dri/${dev##*/}"
echo -e "\e[1;33m""${#DRM_DEVICES_LIST[@]} DRM render nodes available, ${SOMMELIER_DRM_DEVICE} will be used.""\e[0m"
break
fi
done
else
# if only one node available, use it directly
SOMMELIER_DRM_DEVICE="/dev/dri/${DRM_DEVICES_LIST[0]##*/}"
fi
export SOMMELIER_DRM_DEVICE
exec /lib${LIB_SUFFIX}/ld-linux-*.so.? \
--argv0 ${BINDIR}/sommelier \
--library-path ${BINDIR}/../lib${LIB_SUFFIX} \
--inhibit-rpath '' \
${BINDIR}/sommelier.elf \
--display=wayland-0 \
--drm-device=${SOMMELIER_DRM_DEVICE} \
"${@}"