Skip to content

Commit

Permalink
Allow xrandr to fail and only set primary display on success
Browse files Browse the repository at this point in the history
  • Loading branch information
yfyf committed Oct 31, 2024
1 parent a5f6b5f commit 19bf369
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions application/select-display.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 19bf369

Please sign in to comment.