From 13c4aca5ac62ea7ae322d68e6003857816ba79f2 Mon Sep 17 00:00:00 2001 From: Piplup Date: Thu, 13 Mar 2025 17:52:32 +0000 Subject: [PATCH 1/3] Attempt to get desktop scaling factor from the environment directly. --- distribution/linux/Ryujinx.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/distribution/linux/Ryujinx.sh b/distribution/linux/Ryujinx.sh index daeea9bfd..2c143bca3 100755 --- a/distribution/linux/Ryujinx.sh +++ b/distribution/linux/Ryujinx.sh @@ -20,4 +20,33 @@ if command -v gamemoderun > /dev/null 2>&1; then COMMAND="$COMMAND gamemoderun" fi -exec $COMMAND "$SCRIPT_DIR/$RYUJINX_BIN" "$@" +# Check if user already has a manual Avalonia scaling override or session type is x11 +if [[ -n "${AVALONIA_GLOBAL_SCALE_FACTOR-}" || "$(echo "$XDG_SESSION_TYPE")" == "x11" ]]; then + echo "Scaling: Performed by environment, skipping." >&2 +else + # Attempt to get desktop scaling from environment (GNOME) + if [[ "$(echo "$XDG_CURRENT_DESKTOP")" == "GNOME" ]] && command -v gsettings >/dev/null; then + echo -n 'Scaling: GNOME desktop scaling query...' >&2 + SCALING="$(gsettings get org.gnome.desktop.interface scaling-factor)" + SCALING="${SCALING##* }" + echo "found! Factor: ${SCALING}" >&2 + + # Attempt to get desktop scaling from X Query (Others) + elif command -v xrdb >/dev/null && command -v bc >/dev/null; then + echo -n 'Scaling: X FreeType DPI scaling query...' >&2 + dpi="$(xrdb -get Xft.dpi)" + if [[ -n "${dpi}" ]]; then + SCALING=$(echo "scale=2; ${dpi}/96" | bc) + echo "found! Factor: ${SCALING}" >&2 + fi + fi + + if [[ -z "${SCALING-}" || "${SCALING-}" == "0" ]]; then + echo 'Scaling: Unset scaling value, using default scaling.' >&2 + SCALING="1" + fi + + COMMAND="$COMMAND AVALONIA_GLOBAL_SCALE_FACTOR=$SCALING" +fi + +exec $COMMAND "$SCRIPT_DIR/$RYUJINX_BIN" "$@" \ No newline at end of file From 4e61c3369b1f6e17a91fa8e3b10aba3b9bdd1511 Mon Sep 17 00:00:00 2001 From: Piplup Date: Thu, 13 Mar 2025 17:52:57 +0000 Subject: [PATCH 2/3] Janky GNOME workaround and added a fallback kscreen-doctor implementation if needed. --- distribution/linux/Ryujinx.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/distribution/linux/Ryujinx.sh b/distribution/linux/Ryujinx.sh index 2c143bca3..09bfa999b 100755 --- a/distribution/linux/Ryujinx.sh +++ b/distribution/linux/Ryujinx.sh @@ -20,29 +20,38 @@ if command -v gamemoderun > /dev/null 2>&1; then COMMAND="$COMMAND gamemoderun" fi -# Check if user already has a manual Avalonia scaling override or session type is x11 +# Check if user already has a manual Avalonia scaling override or session type is x11. if [[ -n "${AVALONIA_GLOBAL_SCALE_FACTOR-}" || "$(echo "$XDG_SESSION_TYPE")" == "x11" ]]; then echo "Scaling: Performed by environment, skipping." >&2 else - # Attempt to get desktop scaling from environment (GNOME) - if [[ "$(echo "$XDG_CURRENT_DESKTOP")" == "GNOME" ]] && command -v gsettings >/dev/null; then - echo -n 'Scaling: GNOME desktop scaling query...' >&2 - SCALING="$(gsettings get org.gnome.desktop.interface scaling-factor)" + # Query monitor config directly (GNOME), default display only. + if [[ "$(echo "$XDG_CURRENT_DESKTOP")" == "GNOME" && -f ~/.config/monitors.xml ]] then + echo -n 'Scaling: Monitor config located, querying scale...' >&2 + SCALING="$(grep '"|cut -f1 -d"<")" SCALING="${SCALING##* }" echo "found! Factor: ${SCALING}" >&2 - # Attempt to get desktop scaling from X Query (Others) - elif command -v xrdb >/dev/null && command -v bc >/dev/null; then - echo -n 'Scaling: X FreeType DPI scaling query...' >&2 + # Fallback to X DPI query for others. + # Plasma handles this fine, GNOME will always round up e.g. 1.25 -> 2.00. + elif command -v xrdb >/dev/null; then + echo -n 'Scaling: Attempting to get scaling from X DPI value...' >&2 dpi="$(xrdb -get Xft.dpi)" if [[ -n "${dpi}" ]]; then SCALING=$(echo "scale=2; ${dpi}/96" | bc) - echo "found! Factor: ${SCALING}" >&2 fi + echo "found! Factor: ${SCALING}" + + # Query kscreen-doctor for Plasma as a fallback. + elif [[ "$(echo "$XDG_CURRENT_DESKTOP")" == "KDE" ]] && command -v kscreen-doctor >/dev/null; then + echo -n 'Scaling: Attempting to get Plasma desktop scaling factor...' >&2 + SCALING="$(kscreen-doctor --outputs | grep "Scale" -m 1)" + SCALING="${SCALING##* }" + SCALING=$(echo $SCALING | sed 's/\x1B\[[0-9;]*m//g') # Trim ANSI chars from ksd output. + echo "found! Factor: ${SCALING}" fi if [[ -z "${SCALING-}" || "${SCALING-}" == "0" ]]; then - echo 'Scaling: Unset scaling value, using default scaling.' >&2 + echo 'Unset invalid scaling value' >&2 SCALING="1" fi From 42518f2304f57b1595031148ad249907dd25eb25 Mon Sep 17 00:00:00 2001 From: Piplup Date: Thu, 13 Mar 2025 17:55:48 +0000 Subject: [PATCH 3/3] Github feedback --- distribution/linux/Ryujinx.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/distribution/linux/Ryujinx.sh b/distribution/linux/Ryujinx.sh index 09bfa999b..b697aa2b1 100755 --- a/distribution/linux/Ryujinx.sh +++ b/distribution/linux/Ryujinx.sh @@ -21,7 +21,7 @@ if command -v gamemoderun > /dev/null 2>&1; then fi # Check if user already has a manual Avalonia scaling override or session type is x11. -if [[ -n "${AVALONIA_GLOBAL_SCALE_FACTOR-}" || "$(echo "$XDG_SESSION_TYPE")" == "x11" ]]; then +if [ -n "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ] || [ "$XDG_SESSION_TYPE" = "x11" ]; then echo "Scaling: Performed by environment, skipping." >&2 else # Query monitor config directly (GNOME), default display only. @@ -37,16 +37,14 @@ else echo -n 'Scaling: Attempting to get scaling from X DPI value...' >&2 dpi="$(xrdb -get Xft.dpi)" if [[ -n "${dpi}" ]]; then - SCALING=$(echo "scale=2; ${dpi}/96" | bc) + SCALING=$(awk -vdpi="$dpi" 'BEGIN{print dpi/96}') fi echo "found! Factor: ${SCALING}" # Query kscreen-doctor for Plasma as a fallback. elif [[ "$(echo "$XDG_CURRENT_DESKTOP")" == "KDE" ]] && command -v kscreen-doctor >/dev/null; then - echo -n 'Scaling: Attempting to get Plasma desktop scaling factor...' >&2 - SCALING="$(kscreen-doctor --outputs | grep "Scale" -m 1)" - SCALING="${SCALING##* }" - SCALING=$(echo $SCALING | sed 's/\x1B\[[0-9;]*m//g') # Trim ANSI chars from ksd output. + # gsub strips ANSI color codes from ksd output + SCALING=$(kscreen-doctor --outputs | awk '/Scale:/{gsub(/\x1b\[[0-9;]*m/,""); print $2; exit}') echo "found! Factor: ${SCALING}" fi