From 19bf369afa32f80101a42daa0e12520755e1ee29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignas=20Vy=C5=A1niauskas?= Date: Thu, 31 Oct 2024 12:16:41 +0200 Subject: [PATCH] Allow xrandr to fail and only set primary display on success --- application/select-display.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/application/select-display.sh b/application/select-display.sh index fa242d42..2983f510 100755 --- a/application/select-display.sh +++ b/application/select-display.sh @@ -27,22 +27,24 @@ esac if [ -z "$CONNECTED_OUTPUTS" ]; then echo "No connected outputs found. Attempting to apply xrandr globally." - xrandr "${scaling_pref_params[@]}" + xrandr --auto # this is kind of useless? else - first_output="" + + first_functional_output="" for output in $CONNECTED_OUTPUTS; do - if [ -z "$first_output" ]; then - first_output=$output - xrandr --output "$output" \ - --primary \ - "${scaling_pref_params[@]}" + if [ -z "$first_functional_output" ]; then + if xrandr --output "$output" --primary "${scaling_pref_params[@]}"; then + first_functional_output=$output + echo "Configured display $output as primary" + else + echo "Failed to configure display $output" + fi else xrandr --output "$output" \ - --same-as "$first_output" \ - "${scaling_pref_params[@]}" + --same-as "$first_functional_output" \ + "${scaling_pref_params[@]}" || echo "Failed to configure display $output" fi done - fi