From 35722dfa847a0e19192b568ab978b5813514a97d Mon Sep 17 00:00:00 2001 From: "Josh.5" Date: Mon, 11 Sep 2023 20:24:56 +1200 Subject: [PATCH] Add a fallback to a possible existing supported mode when auto switching refresh rates --- overlay/usr/bin/sunshine-run | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/overlay/usr/bin/sunshine-run b/overlay/usr/bin/sunshine-run index a1bebdc..1913b28 100755 --- a/overlay/usr/bin/sunshine-run +++ b/overlay/usr/bin/sunshine-run @@ -85,11 +85,19 @@ if ([ "X${SUNSHINE_CLIENT_WIDTH:-}" != "X" ] && [ "X${SUNSHINE_CLIENT_HEIGHT:-}" xrandr --newmode "${__client_mode:?}" ${__client_modeline##*\"} echo " - Adding new mode '${__client_mode:?}' to device '${__primary_output:?}'" xrandr --addmode "${__primary_output:?}" "${__client_mode:?}" + __mode_added=$? fi # Set the current resoultion to the new mode - echo " - Setting the display mode to '${__client_mode:?}'" - xrandr --output "${__primary_output:?}" --mode "${__client_mode:?}" --rate "${SUNSHINE_CLIENT_FPS:?}" + if [ "${__mode_added:?}" -gt 0 ]; then + echo " - Attempting to set the display mode to a supported '${SUNSHINE_CLIENT_WIDTH:?}x${SUNSHINE_CLIENT_HEIGHT:?}' mode" + xrandr --output "${__primary_output:?}" --mode ${SUNSHINE_CLIENT_WIDTH:?}x${SUNSHINE_CLIENT_HEIGHT:?} --refresh ${SUNSHINE_CLIENT_FPS:?} + [ $? -eq 0 ] && echo " - SUCCESS" + else + echo " - Setting the display mode to '${__client_mode:?}'" + xrandr --output "${__primary_output:?}" --mode "${__client_mode:?}" --rate "${SUNSHINE_CLIENT_FPS:?}" + [ $? -eq 0 ] && echo " - SUCCESS" + fi # Save original display settings to config file. This will be read and used to restore the original display settings when the client disconnects. echo "primary_output='${__primary_output:?}'" >> /tmp/sunshine-exec-run.conf