From 960b808457892fb9ebdc1322b04670e2af7cb14b Mon Sep 17 00:00:00 2001 From: Boris Yumankulov Date: Wed, 9 Jul 2025 21:25:14 +0500 Subject: [PATCH] feat: added compatibility with ChimeraOS configuration and device-quirks Signed-off-by: Boris Yumankulov --- README.md | 37 +++++++++++++++++++++- usr/bin/portproton-gamescope | 60 ++++++++++++++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 16547c1..914fa32 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,48 @@ # PortProtonQt session This project is not affiliated with Valve (wide inspiration was taken from -their work on the SteamDeck). This configuration depends on [gamescope-session](https://raw.githubusercontent.com/ChimeraOS/gamescope-session) from the ChimeraOS project. and [portprotonqt](https://git.linux-gaming.ru/Boria138/PortProtonQt) +their work on the SteamDeck) ## Basic manual setup Copy this repository file structure into the appropriate places and you'll be able to start the session on any Display Manager of your choice. +# User Configuration + +The session sources environment from `~/.config/environment.d/*.conf` files. +The easiest way to configure the session is to create `~/.config/environment.d/gamescope-session-plus.conf` +and set variables there: + +```bash +# Size of the screen. If not set gamescope will detect native resolution from drm. +SCREEN_HEIGHT=2160 +SCREEN_WIDTH=3840 + +# Internal render size of the screen. If not set, will be the same as SCREEN_HEIGHT and SCREEN_WIDTH. +INTERNAL_WIDTH=1280 +INTERNAL_HEIGHT=800 + +# Orientation adjustment of panel, possible values: left, right +ORIENTATION=left + +# Enable VRR +ADAPTIVE_SYNC=1 + +# Treat the internal panel as an external monitor +PANEL_TYPE=external + +# Set priority of display connectors +OUTPUT_CONNECTOR='*,DSI-1' + +# Set the specific values allowed for refresh rates +CUSTOM_REFRESH_RATES=40,50,60 + +# DRM mode generation algorithm (cvt, fixed) +# TODO: what is this ? +DRM_MODE=fixed +``` + # License & Contributing The project is licensed under GPL v3 license. If you want to contribute, diff --git a/usr/bin/portproton-gamescope b/usr/bin/portproton-gamescope index c015193..7582efd 100755 --- a/usr/bin/portproton-gamescope +++ b/usr/bin/portproton-gamescope @@ -1,5 +1,18 @@ #!/usr/bin/env bash +gamescope_has_option() { + if (gamescope --help 2>&1 | grep -e "$1" > /dev/null); then + return 0 + fi + + return 1 +} + +# Source device quirks if exists +if [ -f /usr/share/gamescope-session-plus/device-quirks ]; then + . /usr/share/gamescope-session-plus/device-quirks +fi + # Source user configuration from ~/.config/environment.d set -a for i in "${HOME}"/.config/environment.d/*.conf; do @@ -8,12 +21,55 @@ done set +a # Gamescope parameters -GAMESCOPE_PARAMS="" +: "${OUTPUT_CONNECTOR:=*,eDP-1}" +GAMESCOPE_PARAMS="--prefer-output $OUTPUT_CONNECTOR" # Check if NVK driver is in use if vulkaninfo 2>/dev/null | grep -i "driverName" | grep -q "NVK"; then # Workaround for https://gitlab.freedesktop.org/mesa/mesa/-/issues/13478 - GAMESCOPE_PARAMS+=" --backend sdl -f" + BACKEND="sdl" + GAMESCOPE_PARAMS+=" -f" +fi + +if [ -n "$SCREEN_WIDTH" ] && [ -n "$SCREEN_HEIGHT" ]; then + GAMESCOPE_PARAMS+=" -W $SCREEN_WIDTH -H $SCREEN_HEIGHT" +fi + +if [ -n "$INTERNAL_WIDTH" ] && [ -n "$INTERNAL_HEIGHT" ] ; then + GAMESCOPE_PARAMS+=" -w $INTERNAL_WIDTH -h $INTERNAL_HEIGHT" +fi + +if [ -n "$DRM_MODE" ] ; then + GAMESCOPE_PARAMS+=" --generate-drm-mode $DRM_MODE" +fi + +if [ -n "$ORIENTATION" ] ; then + GAMESCOPE_PARAMS+=" --force-orientation $ORIENTATION" +fi + +if [ -n "$ADAPTIVE_SYNC" ]; then + GAMESCOPE_PARAMS+=" --adaptive-sync" +fi + +if [ -n "$PANEL_TYPE" ] && gamescope_has_option "--force-panel-type"; then + GAMESCOPE_PARAMS+=" --force-panel-type $PANEL_TYPE" +fi + +if [ -n "$CUSTOM_REFRESH_RATES" ] && gamescope_has_option "--custom-refresh-rates"; then + GAMESCOPE_PARAMS+=" --custom-refresh-rates $CUSTOM_REFRESH_RATES" +fi + +if [ -n "$USE_ROTATION_SHADER" ] && gamescope_has_option "--use-rotation-shader"; then + GAMESCOPE_PARAMS+=" --use-rotation-shader $USE_ROTATION_SHADER" +fi + +if [ -n "$BACKEND" ] && gamescope_has_option "--backend"; then + GAMESCOPE_PARAMS+=" --backend $BACKEND" +fi + +if [ -f "$CURSOR_FILE" ]; then + # Use specified cursor if file exists + GAMESCOPE_PARAMS+=" --cursor ${CURSOR_FILE}" fi # Prefer a specific Vulkan adapter if defined