Skip to content

Commit

Permalink
sommelier => 20220324
Browse files Browse the repository at this point in the history
  • Loading branch information
supechicken authored Apr 4, 2022
1 parent d9cad2d commit 81d18e9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion platform2
Submodule platform2 updated from 3b79e6 to e2a86f
24 changes: 23 additions & 1 deletion sommelier-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,33 @@ ARCH="$(uname -m)"
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=/dev/dri/renderD128 \
--drm-device=${SOMMELIER_DRM_DEVICE} \
"${@}"
5 changes: 4 additions & 1 deletion sommelier.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
set -a

SOMMELIER_ACCELERATORS='Super_L,<Alt>bracketleft,<Alt>bracketright'
Expand All @@ -11,7 +12,9 @@ XAUTHORITY=/home/chronos/.Xauthority

case "$(uname -m)" in
x86_64|i686)
if [[ "$(sort -V <<< "$(uname -r)"$'\n'"4.16.0" | tail -n1)" == "4.16.0" ]]; then
# (Intel iGPU only) the newer Iris driver requires kernel 4.16+, use i965 driver instead on kernels before version 4.16
if [[ "$(/usr/sbin/lspci)" =~ 'VGA compatible controller: Intel' && \
"$(sort -V <<< "$(uname -r)"$'\n'"4.16.0" | tail -n1)" == "4.16.0" ]]; then
MESA_LOADER_DRIVER_OVERRIDE=i965
fi
;;
Expand Down
9 changes: 5 additions & 4 deletions sommelierd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
#!/usr/bin/env -S ruby --disable-all
require 'fileutils'
require 'securerandom'

Expand Down Expand Up @@ -109,16 +109,17 @@ end

def stop_somm
# stop_somm: kill sommelier process listed in /tmp/sommelier-*.pid files
x_pid = File.read('/tmp/sommelier-x.pid') if File.exist?('/tmp/sommelier-x.pid')
wl_pid = File.read('/tmp/sommelier-wl.pid') if File.exist?('/tmp/sommelier-wl.pid')
x_pid = ( File.exist?('/tmp/sommelier-x.pid') ) ? File.read('/tmp/sommelier-x.pid') : nil
wl_pid = ( File.exist?('/tmp/sommelier-wl.pid') ) ? File.read('/tmp/sommelier-wl.pid') : nil

[ x_pid, wl_pid ].each do |pid|
[ x_pid, wl_pid ].reject(&:nil?).each do |pid|
begin
Process.kill('TERM', pid.to_i)
rescue Errno::ESRCH
end
end

sleep 0.5 # ensure the daemon processes have been killed
puts "sommelier stopped"
end

Expand Down
13 changes: 10 additions & 3 deletions sommelierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S bash
#!/usr/bin/env bash
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand All @@ -12,8 +12,15 @@ set -o pipefail

# Set Xft.dpi. Some applications (e.g. Chrome) use this to detect HiDPI.
if { command -v xdpyinfo && command -v xrdb; } > /dev/null; then
# 1.25x of the DPI reported by xdpyinfo = the DPI reported by xdpyinfo in Crostini
DPI="$(( $(xdpyinfo | sed -n -E "/dots per inch/{s|^.* ([0-9]+)x.*$|\\1|g; p}") / 4 * 5 ))"
DPI="$(xdpyinfo | sed -n -E "/dots per inch/{s|^.* ([0-9]+)x.*$|\\1|g; p}")"

if [[ -n "${SOMMELIER_APPLY_DPI_FIX:-}" ]]; then
# the DPI returned by xdpyinfo might be incorrect, workaround below fixes the value:
# 1.25x of the DPI reported by xdpyinfo = the DPI reported by xdpyinfo in Crostini
echo -e "\e[1;34m""Applying DPI fix...""\e[0m"
DPI="$(( ${DPI} / 4 * 5 ))"
fi

xrdb -merge <<< "Xft.dpi: ${DPI}"

# Set cursor theme
Expand Down

0 comments on commit 81d18e9

Please sign in to comment.